Using csh commands within the system() function call

Conor P. Cahill cpcahil at virtech.uucp
Sun Jan 14 08:33:12 AEST 1990


In article <239 at tnl.UUCP>, saf at tnl.UUCP (friedman scott) writes:
> I wish to use a system command that works under csh but not under sh within
> a system() function call in a C program.  The line looks something like this:
> 
>    system("command_that_generates_errors >& /dev/null");


You could modify it so that it will work under sh (like the following):

     system("command_that_generates_errors > /dev/null 2>&1");

or you could fork and execute the program yourself, mapping stdout and stderr
   to /dev/null.

or you could write a new system() like program (maybe csystem()) that

	forks
	if child runs csh -c arg_string;
	waits
	returns



-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.unix.questions mailing list