home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / perl / 5890 < prev    next >
Encoding:
Text File  |  1992-09-12  |  2.1 KB  |  57 lines

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