Using csh commands within the system() function call

Jonathan I. Kamens jik at athena.mit.edu
Mon Jan 15 15:08:15 AEST 1990


In article <1990Jan13.213312.6620 at virtech.uucp>, cpcahil at virtech.uucp (Conor P.
Cahill) writes:
> 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");
> 
> [suggests modifying the command to work under sh, or forking and execing the
>  process without using system, or writing a new system function to use csh]

  Or, you could just use the easiest solution, which is to tell /bin/sh
to use /bin/csh when parsing the command:

    system("/bin/csh -fc 'command_which_generates_errors >& /dev/null'");

(Yes, I know that if the /bin/csh which is executed prints out an error,
then it will be printed in the calling process.  I don't consider that
such a bad thing, given that if the shell has to print out an error then
there is something very wrong....)

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list