scripted piped system commands
From: Deb (beginners_at_perl.org)
Date: 12/31/03
- Next message: Rob Dixon: "Re: Help with extracting text"
- Previous message: Jim Halkyard: "RE: : Help with extracting text"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 31 Dec 2003 07:55:29 -0800 To: Perl List <beginners@perl.org>
Happy Almost New Year!
I want to run a unix system command inside a script. From the
shell, here's the command(s):
% ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk '{print $2}'
19460
What is returned is the pid of the process being grep'd.
But, when I put this into a test script,
---- snip ----
my $pid = `ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk '{print $2}'`;
print "\$pid is: $pid \n";
---- snip ----
And, here's the output:
$pid is: root 19460 1 0 Dec 18 ? 0:08 /usr/lib/sendmail -bd
-q15m
It seems to be only going as far as dropping off the grep (grep -v),
and never executing the awk '{print $2}'. I've tried this with
the system() call, with the same results.
Please, what am I missing? :-(
deb
- Next message: Rob Dixon: "Re: Help with extracting text"
- Previous message: Jim Halkyard: "RE: : Help with extracting text"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|