Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions Subject: Re: Using csh commands within the system() function call Keywords: csh sh system Message-ID: <1990Jan15.040815.19847@athena.mit.edu> Date: 15 Jan 90 04:08:15 GMT References: <1990Jan13.213312.6620@virtech.uucp> <239@tnl.UUCP> Sender: news@athena.mit.edu (News system) Reply-To: jik@athena.mit.edu (Jonathan I. Kamens) Organization: Massachusetts Institute of Technology Lines: 26 In article <1990Jan13.213312.6620@virtech.uucp>, cpcahil@virtech.uucp (Conor P. Cahill) writes: > In article <239@tnl.UUCP>, saf@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@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8495 Home: 617-782-0710