Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!spool.mu.edu!uunet!rbj From: rbj@uunet.UU.NET (Root Boy Jim) Newsgroups: comp.lang.perl Subject: Re: Getting output from stderr Message-ID: <123560@uunet.UU.NET> Date: 22 Feb 91 03:40:31 GMT References: Distribution: comp Organization: UUNET Communications Services, Falls Church, VA Lines: 20 In article victor@ibm.com writes: >Suppose that foo is a system command, which produces output on STDOUT, >and might produce output on STDERR. How can I capture both in perl >variables (short of redirecting STDERR to a file - ugh!)? Two ways: First, you ask nicely: "Larry, I know I can say: $out = `cmd args`; but I want stderr too, so how about if I say: ($out,$err) = `cmd args`; what do you think?" To which Larry will probably respond: "I'm too busy hacking in even parity generation of BCD trigraphs for RBJ, so take a hike." More likely, you open two pipes, fork, do the standard plumbing, exec the command in the child, have the parent select on the two pipes until you've sucked them dry, wait on the child, then close the parent's pipes. Hmmmm, that temporary file looks pretty good now don't it? -- [rbj@uunet 1] stty sane unknown mode: sane