> I figured the nidump command with parameters would work too
But only if you put "passwd" into args
In fact, it should be more like this
Code:
char *args[] = {
"/usr/bin/nidump",
"passwd"
NULL};
...
execve(args[0], args, NULL);
> I realized you said it wasn't possible to re-direct I/O
No, I said it was tricky in DOS
In unix/linux, its much easier
Code:
} else if(PID == 0) {
int fd = open( argv[1], O_WRONLY ); // This is >, if you want >> bitwise the flag with O_APPEND
close( 1 ); // existing stdout is no more
dup( fd ); // stdout is now fd
printf("child pid: %d\n", getpid());
execve(args[0], args, NULL);
if(errno == -1) {
perror("error");
}
}
> char *argv[] = {"ping", "-c 5", ping_host, NULL};
It might work, though I would have said
char *argv[] = {"ping", "-c", "5", ping_host, NULL};
Remember, every white space separates the args on the command line (as you type it in), and this must be reflected in any argv[] you construct.