Date: Tue, 13 Nov 2001 06:29:41 +0000 From: Mark Hill <slurpcandy@btinternet.com> To: freebsd-newbies@FreeBSD.ORG Subject: Re: Perl on FreeBSD Message-ID: <20011113062941.A16899@turtle.turtle> In-Reply-To: <5.1.0.14.2.20011113110529.038222a8@mail.ideal.net.au> References: <258bb29fb0.29fb0258bb@drustvo-dns.si> <20011112231605.A16432@turtle.turtle> <5.1.0.14.2.20011113110529.038222a8@mail.ideal.net.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Nov 13, 2001 at 11:11:28AM +1100, Chris Aitken wrote: > Hi everyone.... > > > I have a curley on I havent been able to work out. > > What I want to be able to do is take the output of a FreeBSD command, and > pipe the output to a perl script so I can use that data.... > > For example. If I ran the following at command line, > > # echo "Blah Blah Blah" | perlscript.pl > > How would I be able to print "Blah Blah Blah" to the screen from the perl > script. I am only new to perl and have been doing alot of funky mrtg stuff > opening files and commands within the perl script and taking the output, > but im stumped on how to pipe data to a perl script and use that data in > the perl script. > > > Any assistance would be great. > > > > Thanks > > > Chris > > > > -- > Chris Aitken - Administration/Database Designer - IDEAL Internet > email: chris@ideal.net.au phone: +61 2 4628 8888 fax: +61 2 4628 8890 > __-----------------------------------------__ > # ln -s /dev/null /bin/laden > If you don't like my typing, all flames to /bin/laden > > Hi, I think there's a few ways of doing what you want. One is using <STDIN>. E.g #!/usr/bin/perl -w $name = <STDIN>; print $name; The above will take one line of standard input. I make the perl script executable (chmod +x perlscript.pl), so when I do the following echo "Mark" | perlscript.pl I get the result of: Mark There's also a thing called @ARGV, but I'd have trouble explaining that. It's usually used to take names of file names like, perlscript.pl file1 file2 file3 That may be more useful to you. Go to www.perlmonks.org for more info. That's a quality site. -- Mark Hill - http://www.fero.uklinux.net Hoping not to fall in the 'it works like that in Linux' trap Using FreeBSD 4.2 in vmware 3.0, on top of Slackware Linux 8.0 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-newbies" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011113062941.A16899>