Do you want to replace the command with Perl script completely?
Or do you just want to get rid of grep?
A script for the second case:
Code:
#!/usr/bin/perl
use strict;
my $CMD = '/bin/sh /opt';
my $C = qr/$CMD/;
my $run = 1;
while($run) {
open I, "ps -ef |" || die "Cannot open pipe";
$_ = <I>;
last unless scalar (grep { /$C/ } map { /^(?:\S+\s+){7}(.*)$/; $1 } <I>);
print localtime(time) . ": Still running...\n";
close I;
}
(UPDATE)
...but the script above by
mmrtnt does the same in a much simpler way...