home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / perl / 5866 < prev    next >
Encoding:
Internet Message Format  |  1992-09-11  |  1.5 KB

  1. 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
  2. From: merlyn@ora.com (Randal L. Schwartz)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: What's the difference between `command` and system('command')?
  5. Message-ID: <MERLYN.92Sep11085435@romulus.reed.edu>
  6. Date: 11 Sep 92 15:54:38 GMT
  7. Article-I.D.: romulus.MERLYN.92Sep11085435
  8. References: <sasswb.716131013@k2> <1992Sep10.183530.21405@news.eng.convex.com>
  9.     <peter.716216984@merlin>
  10. Sender: news@reed.edu (USENET News System)
  11. Organization: Stonehenge Consulting Services; Portland, Oregon, USA
  12. Lines: 18
  13. In-Reply-To: peter@merlin.acadiau.ca's message of Fri, 11 Sep 1992 13:09:44 GMT
  14.  
  15. In article <peter.716216984@merlin> peter@merlin.acadiau.ca (Peter Steele) writes:
  16.    Where does error output go (i.e., stderr)? I have an application
  17.    where I want to capture error output, not stdout.
  18.  
  19. stdin and stderr are inherited from the Perl process for backticks.
  20. Use /bin/sh redirection to dup them to the proper places:
  21.  
  22.     $foo = `some_command 2>&1`; # get both stderr and stdout in string
  23.     $bar = `some_cmd 2>&1 >/dev/null`; # get *only* stderr
  24.  
  25. It's important not to reverse those two redirections in the second
  26. example, or you'll get nothing!
  27.  
  28. print `perl -e 'die "Just another Perl hacker,\n"' 2>&1`
  29. --
  30. Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
  31. merlyn@reed.edu (guest account) merlyn@ora.com (better for permanent record)
  32. cute quote: "Welcome to Portland, Oregon -- home of the California Raisins!"
  33.