Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: shell stderr in popen() Message-ID: <7928@mimsy.UUCP> Date: Sun, 9-Aug-87 13:27:56 EDT Article-I.D.: mimsy.7928 Posted: Sun Aug 9 13:27:56 1987 Date-Received: Sun, 9-Aug-87 23:05:13 EDT References: <4511@sunybcs.UUCP> Distribution: na Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 22 Keywords: shell popen stderr redirection >In article <124@foobar.UUCP> tw@foobar.UUCP (Tom Walsh) writes: >>[Using] popen(command, "r") ... i would like to dispose quietly of >>the shell's complaint: >> sh: command: not found In article <4511@sunybcs.UUCP> ugbinns@sunybcs.uucp (Leonard Binns) writes: >Did you ever try: > popen("/usr/bin/mynewcommand -flags 2>& /dev/null", "r"); This will not do it. (For one thing, it is syntactically invalid.) The shell prints `sh: : not found' to the *shell's* standard error output, before any redirection. There are several possible solutions, but the easiest is to add one level of indirection: (void) sprintf(expandcmd, "sh -c '%s' 2>/dev/null", command); iop = popen(expandcmd, "r"); Note that this assumes `command' has no single quotes embedded in it. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: seismo!mimsy!chris