home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!spool.mu.edu!agate!dog.ee.lbl.gov!hellgate.utah.edu!fcom.cc.utah.edu!park.uvcc.edu!ns.novell.com!jkt
- From: jkt@SED.Provo.Novell.COM (Jack Thomasson)
- Subject: Re: stdout from 'system'?
- In-Reply-To: lynch@hpcc01.corp.hp.com's message of Wed, 9 Sep 1992 23:01:34 GMT
- Message-ID: <JKT.92Sep13005356@seneca.SED.Provo.Novell.COM>
- Sender: usenet@Novell.COM (Usenet News)
- Nntp-Posting-Host: seneca.sed.provo.novell.com
- Organization: Novell, Inc.
- References: <1180030@hpcc01.corp.hp.com>
- Date: Sun, 13 Sep 1992 07:53:56 GMT
- Lines: 46
-
- >>>>> On Wed, 9 Sep 1992 23:01:34 GMT, lynch@hpcc01.corp.hp.com
- >>>>> (Howard Lynch) said:
-
- Howard> Specific: I want to get the hostname of the system my perl
- Howard> script is running on into a script variable.
-
- use the backticks operator!
-
- Howard> The ksh equivalent would be:
-
- Howard> HOST=`hostname`
- Howard> echo $HOST
-
- and the perl equivalent is:
-
- chop($HOST = `hostname`); # remove trailing newline also
-
- Howard> General: I want to get the stdout from a unix command into a
- Howard> script variable. It would seem like I should be able to use
- Howard> the 'system' command and capture its stdout into a script
- Howard> variable.
-
- $OUTPUT = `command`;
-
- or
-
- @OUTPUT = `command`;
-
- just be careful: perl will gladly (now how did Larry put it? man
- perl; ah, yes!) "slurp in your whole file as a single string". i
- wouldn't recommend:
-
- $OUTPUT = `find / -exec cat {} \;`;
-
- Howard> Thanks for any feedback.
-
- Howard> Howard Lynch
- Howard> HP OCD IC Manufacturing
- Howard> hl@hpocia.sj.hp.com
- --
- ---------------------------------------------------------------------
- Jack Thomasson :{)} (the bearded one)
- Internet:Jack_Thomasson@Novell.COM MHS:JKT@NOVELL
- Novell Consulting Services\E-23-2\122 East 1700 South\Provo, UT 84606
- Phone: (800)453-1267x7604 | (801)429-7604 FAX: (801)429-5511
- "WARNING: the comments do not necessarily reflect the implementation"
-