From owner-freebsd-newbies Mon Nov 12 22:30: 8 2001 Delivered-To: freebsd-newbies@freebsd.org Received: from praseodumium.btinternet.com (praseodumium.btinternet.com [194.73.73.82]) by hub.freebsd.org (Postfix) with ESMTP id 0757437B405 for ; Mon, 12 Nov 2001 22:30:03 -0800 (PST) Received: from [213.122.219.11] (helo=turtle.mutantturtle) by praseodumium.btinternet.com with esmtp (Exim 3.22 #6) id 163X56-0004xI-00 for freebsd-newbies@FreeBSD.ORG; Tue, 13 Nov 2001 06:30:01 +0000 Received: (from mark@localhost) by turtle.mutantturtle (8.11.4/8.11.4) id fAD6Tgq16936 for freebsd-newbies@FreeBSD.ORG; Tue, 13 Nov 2001 06:29:42 GMT Date: Tue, 13 Nov 2001 06:29:41 +0000 From: Mark Hill To: freebsd-newbies@FreeBSD.ORG Subject: Re: Perl on FreeBSD Message-ID: <20011113062941.A16899@turtle.turtle> Mail-Followup-To: freebsd-newbies@FreeBSD.ORG References: <258bb29fb0.29fb0258bb@drustvo-dns.si> <20011112231605.A16432@turtle.turtle> <5.1.0.14.2.20011113110529.038222a8@mail.ideal.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5.1.0.14.2.20011113110529.038222a8@mail.ideal.net.au> User-Agent: Mutt/1.3.21i Organization: Very little X-OS: Slackware Linux 8.0 X-Uptime: up 2 days 2 hours 35 minutes X-No-Archive: Yes Sender: owner-freebsd-newbies@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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 . E.g #!/usr/bin/perl -w $name = ; 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