> -----Original Message-----
> From: Baartmans, Hans [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 21, 2001 4:04 PM
> To: [EMAIL PROTECTED]
> Subject: Check to see if process exists
>
>
> Is there good way to execute a UNIX 'ps' command from Perl
> and check to see
> if a process is running or exists? For instance, I would
> like to check to
> see if Sendmail is running. Under a UNIX shell command you
> can execute,
> '/usr/bin/ps -ef | grep sendmail'.
>
> Is there an easy way to do this in Perl?
Use backticks to capture the ps -ef output and search for
sendmail. I wouldn't send the ps|grep pipeline to the backticks,
because on my system the ps output includes the grep command,
which might give a "false positive".
print "sendmail is up\n" if `ps -ef` =~ /sendmail/;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]