Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!ames!amdcad!amd!intelca!mipos3!omepd!littlei!foobar!tw From: tw@foobar.UUCP (Tom Walsh) Newsgroups: comp.unix.wizards Subject: shell stderr in popen() Message-ID: <124@foobar.UUCP> Date: Mon, 3-Aug-87 21:05:37 EDT Article-I.D.: foobar.124 Posted: Mon Aug 3 21:05:37 1987 Date-Received: Sat, 8-Aug-87 11:19:30 EDT Sender: news@foobar.UUCP Distribution: na Organization: - Intel Corp - Hawthorne Farms - Hillsboro, OR - Lines: 33 Keywords: shell popen stderr redirection hi, sortof like the scanf() contest... i have a need to use popen(command, "r"). if command is not found, i would like to dispose quietly of the shell's complaint: sh: command: not found the stderr of the command itself can be handled ala: popen("/usr/bin/mynewcommand -flags 2> /dev/null", "r"); but if "mynewcommand" isn't around, the shell's stderr still gets put on the *real* stderr. question: is there an easier way than: . . . realerr = dup(stderr); freopen("/dev/null", "w", stderr); popen(); do_stuff(); pclose(); fclose(stderr); dup2(realerr, stderr); . . . to get rid of the shell's stderr???? -tw (Tom Walsh, (503)696-7105, Intel Corp; Hillsboro OR) ...tektronix!psu-cs!omosys! \ ...seismo!vrdxhq!verdix!omepd!littlei! \ ...intelisc! >foobar!tw ...inteloa! / ...omepd!littlei! /