home *** CD-ROM | disk | FTP | other *** search
- From: lynch@hpcc01.corp.hp.com (Howard Lynch)
- Date: Wed, 9 Sep 1992 23:01:34 GMT
- Subject: stdout from 'system'?
- Message-ID: <1180030@hpcc01.corp.hp.com>
- Organization: OCD IC MFG
- 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
- Newsgroups: comp.lang.perl
- Lines: 26
-
- I have a specific and general question:
-
- Specific: I want to get the hostname of the system my perl script is running
- on into a script variable.
-
- The ksh equivalent would be:
-
- HOST=`hostname`
- echo $HOST
-
- The best way I can figure out to do this with perl is:
-
- open(ASDF,"hostname|");
- chop($hostname=<ASDF>);
- close(ASDF);
- print "hostname = $hostname";
-
- General: I want to get the stdout from a unix command into a script variable.
- It would seem like I should be able to use the 'system' command
- and capture its stdout into a script variable.
-
- Thanks for any feedback.
-
- Howard Lynch
- HP OCD IC Manufacturing
- hl@hpocia.sj.hp.com
-