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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!s5!is1.is.morgan.com!is.morgan.com!robt
  3. From: robt@is.morgan.com (Rob Torop)
  4. Subject: Re: What's the difference between `command` and system('command')?
  5. Message-ID: <1992Sep11.161827@is.morgan.com>
  6. Sender: news@is.morgan.com
  7. Nntp-Posting-Host: idt101
  8. Organization: Morgan Stanley - IS
  9. References: <sasswb.716131013@k2> <1992Sep10.183530.21405@news.eng.convex.com> <peter.716216984@merlin>
  10. Date: Fri, 11 Sep 1992 20:18:27 GMT
  11. Lines: 27
  12.  
  13. In article <peter.716216984@merlin>, peter@merlin.acadiau.ca (Peter Steele) writes:
  14. |> >:What the difference between saying `some Unix command` and
  15. |> >:system('some Unix command')?  Are they synonymous?  Are there situations
  16. |> >:where one is better than the other?
  17. |> 
  18. |> >    `cmd`;
  19. |> >    $line = `cmd`;
  20. |> >    @lines = `cmd`;
  21. |> 
  22. |> >returns the output, as it does in the shell.  The first form,
  23. |> >however, throws it away.  system() works much (although not
  24. |> >quite exactly) as it does in C.
  25. |> 
  26. |> Where does error output go (i.e., stderr)? I have an application
  27. |> where I want to capture error output, not stdout.
  28.  
  29. How about
  30.  
  31.     @lines = `cmd 2>&1`;
  32.  
  33. This runs cmd with stderr redirected to stdout.  It works with ksh - I don't know about csh.q
  34.  
  35. -- Rob Torop
  36.  
  37. +---------------------------------------------------------------------+
  38. | The views expressed here are neither mine nor those of my employer. |
  39. +---------------------------------------------------------------------+
  40.