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

  1. From: lynch@hpcc01.corp.hp.com (Howard Lynch)
  2. Date: Wed, 9 Sep 1992 23:01:34 GMT
  3. Subject: stdout from 'system'?
  4. Message-ID: <1180030@hpcc01.corp.hp.com>
  5. Organization: OCD IC MFG
  6. Path: sparky!uunet!paladin.american.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!usc!sdd.hp.com!scd.hp.com!hplextra!hpcc05!hpcc01!lynch
  7. Newsgroups: comp.lang.perl
  8. Lines: 26
  9.  
  10. I have a specific and general question:
  11.  
  12. Specific:  I want to get the hostname of the system my perl script is running
  13.            on into a script variable.
  14.  
  15.            The ksh equivalent would be:
  16.  
  17.                 HOST=`hostname`
  18.                 echo $HOST
  19.  
  20.            The best way I can figure out to do this with perl is:
  21.  
  22.                open(ASDF,"hostname|");
  23.                chop($hostname=<ASDF>);
  24.                close(ASDF);
  25.                print "hostname = $hostname";
  26.  
  27. General:  I want to get the stdout from a unix command into a script variable.
  28.           It would seem like I should be able to use the 'system' command
  29.           and capture its stdout into a script variable.
  30.  
  31. Thanks for any feedback.
  32.  
  33. Howard Lynch
  34. HP OCD IC Manufacturing
  35. hl@hpocia.sj.hp.com
  36.