in reply to Process Monitoring Script

As I have posted before, I am a great proponent of implementing within Perl rather than invoking another shell and relying on external programs. With that in mind, I would recommend the usage of Proc::ProcessTable which I have reviewed previously on this site here.

Using Proc::ProcessTable, your code would look something like this:

use Proc::ProcessTable; my $running = 0; my $proc = Proc::ProcessTable->new; foreach ( @{ $proc->table } ) { if ($_->cmndline =~ /nameofprocess/) { $running = 1; last; } } if (!$running) { # do something to reinvoke process }

Much neater than using non-portable ps calls and nasty regular expressions to my mind :-)

 

perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'