John, thanks for the "perl" approach.  Mustn't forget about that!


deb

At 20:59:59, on 01.02.04:
Cracks in my tinfoil beanie
allowed John W. Krahn to seep these bits into my brain:,
> Deb wrote:
> > 
> > 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
> 
> open PS, 'ps -ef |' or die "Cannot open pipe from 'ps -ef' $!";
> my $pid;
> while ( <PS> ) {
>     next unless m|/usr/lib/sendmail|;
>     $pid = ( split )[ 1 ];
>     last;
>     }
> close PS or die "Cannot close pipe from 'ps -ef' $!";
> 
> 
> Or:
> 
> my $pid;
> for ( `ps -ef` ) {
>     next unless m|/usr/lib/sendmail|;
>     $pid = ( split )[ 1 ];
>     last;
>     }
> 
> 
> Or:
> 
> my ( $pid ) = map +( split )[ 1 ], grep m|/usr/lib/sendmail|, `ps -ef`;
> 
> 
> 
> 
> John
> -- 
> use Perl;
> program
> fulfillment
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 

-- 
                  o      _     _         _
          _o     /\_   _ \\o  (_)\__/o  (_)
        _< \_   _>(_) (_)/<_    \_| \   _|/' \/
       (_)>(_) (_)        (_)   (_)    (_)'  _\o_
               http://zapatopi.net/afdb.html







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