I know that C probably isn't the best language to be scripting in but I'm not too familiar with my linux virtual machine so I'm not sure how easy it would be to install python or java or something.
I'm trying to write a script and I need to be able to get the last line of output from the console. Here's what I have so far:
I think I need the two popens because program1 blocks and I want program2 to still execute. This doesn't print anything even though there's output from program1 and 2Code:void main() { char text[200]; FILE *f1,*f2 ; f1 = popen("./program1" ,"w"); f2 = popen("./program2","w"); while (fgets(text, 200, f2) != NULL) printf("Output is %s", text); }
Thanks
Here's the tutorial I've been following:
http://www.opengroup.org/onlinepubs/...ons/popen.html