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

  1. Path: sparky!uunet!usc!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!malgudi.oar.net!chemabs!srv01s4!jcv26
  2. From: jcv26@cas.org (Jon Vander Hill)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: stdout from 'system'?
  5. Message-ID: <JCV26.92Sep11092835@jcv26aws.cas.org>
  6. Date: 11 Sep 92 14:28:35 GMT
  7. References: <1180030@hpcc01.corp.hp.com>
  8. Sender: usenet@cas.org
  9. Organization: Chemical Abstracts Service, Columbus, Ohio, USA
  10. Lines: 21
  11. In-Reply-To: lynch@hpcc01.corp.hp.com's message of Wed, 9 Sep 1992 23:01:34 GMT
  12.  
  13. In article <1180030@hpcc01.corp.hp.com> lynch@hpcc01.corp.hp.com (Howard Lynch) writes:
  14.  
  15.    I want to get the hostname of the system my perl script is running
  16.    on into a script variable.
  17.  
  18. chop($host=`hostname`);
  19.  
  20.    I want to get the stdout from a unix command into a script variable.
  21.  
  22. $s = `some_command`;             # stdout and stderr
  23. $s = `some_command 2>/dev/null`; # just stdout
  24.  
  25. Assignment to arrays is sometimes useful.  Each member corresponds
  26. to a line of output.  You can also use the 'chop' call as above
  27. with arrays.  This chops newlines from each line read.
  28.  
  29. @a = `some_command 2>/dev/null`; # just stdout
  30.  
  31.  
  32. Jon Vander Hill
  33. jon@cas.org
  34.