C program to mimic using pipes to combine shell commands