home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!caen!uakari.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!ogicse!reed!romulus!merlyn
- From: merlyn@ora.com (Randal L. Schwartz)
- Newsgroups: comp.lang.perl
- Subject: Re: What's the difference between `command` and system('command')?
- Message-ID: <MERLYN.92Sep11085435@romulus.reed.edu>
- Date: 11 Sep 92 15:54:38 GMT
- Article-I.D.: romulus.MERLYN.92Sep11085435
- References: <sasswb.716131013@k2> <1992Sep10.183530.21405@news.eng.convex.com>
- <peter.716216984@merlin>
- Sender: news@reed.edu (USENET News System)
- Organization: Stonehenge Consulting Services; Portland, Oregon, USA
- Lines: 18
- In-Reply-To: peter@merlin.acadiau.ca's message of Fri, 11 Sep 1992 13:09:44 GMT
-
- In article <peter.716216984@merlin> peter@merlin.acadiau.ca (Peter Steele) writes:
- Where does error output go (i.e., stderr)? I have an application
- where I want to capture error output, not stdout.
-
- stdin and stderr are inherited from the Perl process for backticks.
- Use /bin/sh redirection to dup them to the proper places:
-
- $foo = `some_command 2>&1`; # get both stderr and stdout in string
- $bar = `some_cmd 2>&1 >/dev/null`; # get *only* stderr
-
- It's important not to reverse those two redirections in the second
- example, or you'll get nothing!
-
- print `perl -e 'die "Just another Perl hacker,\n"' 2>&1`
- --
- Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
- merlyn@reed.edu (guest account) merlyn@ora.com (better for permanent record)
- cute quote: "Welcome to Portland, Oregon -- home of the California Raisins!"
-