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