I wrote this simple program. I want the output of it to be logged to the test.log as opened below. Is it possible for me to do this?
int main(int argc, char **argv)
{
int fd = open("test.log", O_CREAT|O_WRONLY);
char *path[2];
path[0] = "/bin/ls";
path[1] = NULL;
execve((char *)&path[0], &path, NULL);
close(fd);
return 0;
}
Working solution, as guided by Rici.