how to redirect stdout of a command from kernel space

744 Views Asked by At

I need to redirect stdout of a command invoked from kernel space using the linux usermode helper api. Using "echo" commmand as an example below. This does NOT work.

static int    umh_helper() {
struct subprocess_info *sub_info;
char *argv[] = {"/bin/echo", "Hi", ">", "/tmp/command.out", NULL};
static char *envp[] = {
    "HOME=/root",
    "TERM=linux",
    "PATH=/bin:/sbin:/bin:/usr/sbin:/usr/bin", NULL };
return call_usermodehelper( argv[0], argv, envp, UMH_WAIT_PROC );
}

The command I need to run does NOT support a way to take file name as its input argument to write the output to file directly and hence I need to do this.

0

There are 0 best solutions below