exec and pipes
i have a char* filename and want to determine if the file is an executable file.
first, which is the best way to find that out? i have chosen to use the "file" command. i want to make file post its output to a pipe "pipefile" . my process then reads the pipe contents and checks for the string "executable"
since writing to a pipe blocks i need to fork a child for that.
please see if the following is somewhat sound:
now i really dont know how to call execlp correctly so that file will write its output to the pipe.
int i = fork();
if (i == 0)
hope someone can help me?
ok this works with redirection tricks and is well explained here:
Or use the popen() function.
this looks cool. thanks for the popen hint.
If you wanto get more info about pipes (and also system programming) see the page
I higly recommend anyone want to write system programs to visit the page.
Thanks for the reference.