deb wrote:
Happy Almost New Year!

I want to run a command inside a script. From the shell, here's the command:

% 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,

my $pid = `ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk 
'{print $2}'`;
print "\$pid is: $pid \n";

here's what I'm seeing ,

$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, and not doing the
awk '{print $2}'. I've tried this with the system() call, with the same
results.

Try changing the $2 to \$2. Perl is interpolating $2 before it gets to bash, so bash sees "/bin/awk '{print }'".


--
Andrew Gaffney
System Administrator
Skyline Aeronautics, LLC.
776 North Bell Avenue
Chesterfield, MO 63005
636-357-1548



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to