I'm a novice at C Programming in Unix and need to do a project where I have to execute the command ps -ef | grep username | wc -l to do this I have to write a C code in unix that creates a separate process for each of the commands and then pipes the input and output.
The requirement is that a parent spawns a child process which then spawns another child process. The last child process will execute ps -ef and pass output via pipe to its parent which will execute grep username on the output received and then pass the result to the original parent process which will run wc -l on the results received and output a number on the screen.
Here is what I have so far, the code compiles but I get no output. Please help!!!
execl"wc", "-l", 0);
else if (!fork())
execl("grep", "root", 0);
execl("ps", "-ef", 0);
// never gets here