System() function

Olav Eide olav at nososl.UUCP
Wed Oct 24 03:48:59 AEST 1990


In article <24826 at adm.BRL.MIL> vilva at csvax.csc.lsu.edu (Vilva Natarajan) writes:
>
>I am trying to do system("man cat | wc -c") in my program, and i need
>to store the value returned by "wc" in a variable declared in my program.
>I dont want to redirect it to a file and then read from the file.
>Please advice.
>
Why not use the popen call ?

		 fd = popen("man cat | wc -c","r");
		 fgets(line,LL,fd);
		 sscanf(line,"%d",&your_variable);

You should of course check the return values for popen and fgets



More information about the Comp.unix.internals mailing list