home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!sun-barr!cs.utexas.edu!convex!convex!tchrist
- From: Tom Christiansen <tchrist@convex.COM>
- Subject: Re: What's the difference between `command` and system('command')?
- Originator: tchrist@pixel.convex.com
- Sender: usenet@news.eng.convex.com (news access account)
- Message-ID: <1992Sep12.182531.15014@news.eng.convex.com>
- Date: Sat, 12 Sep 1992 18:25:31 GMT
- Reply-To: tchrist@convex.COM (Tom Christiansen)
- References: <peter.716216984@merlin> <1992Sep11.161827@is.morgan.com> <peter.716295183@merlin>
- Nntp-Posting-Host: pixel.convex.com
- Organization: Convex Computer Corporation, Colorado Springs, CO
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
- Lines: 39
-
- From the keyboard of peter@merlin.acadiau.ca (Peter Steele):
- :>|> Where does error output go (i.e., stderr)? I have an application
- :>|> where I want to capture error output, not stdout.
- :
- :>How about
- :
- :> @lines = `cmd 2>&1`;
- :
- :>This runs cmd with stderr redirected to stdout. It works with ksh - I
- :>don't know about csh.q
- :
- :What's happens to normal stdout in this case? Is it lost?
-
- No, it's merged with stderr.
-
- :Here's what I'm doing:
- : dump 0f - /somefs | compress | dd of=/dev/somedev
-
- :I want to collect the stderr output of each of these commands. The
- :only way I can think of doing this in perl is:
- :
- : `dump 0f - /somefs 2>1.err | compress 2>2.err | dd of=/dev/somedev >3.err`
- :
- :and then open and extract the info I want from the three files that are
- :created. Is this a reasonable way to do this in perl?
-
- Pretty much. While you could in theory play all the dup and fork
- games yourself and avoid temporaries that way, it's not fun.
-
- The shell is much more adroit at such games than perl.
-
- But I would probably just run this in system(), not `cmd`.
-
- --tom
- --
- Tom Christiansen tchrist@convex.com convex!tchrist
- "I sincerely hope that the future does not mean we must continually restrict
- ourselves to the tools that were available 10 years ago."
- Mark Bush in comp.unix.wizards <4235@inca.comlab.ox.ac.uk>
-