in reply to Checking a command is running
First, what are the errors you see? I know of at least two ones ...
Why don't you just write this in sed or awk or some other shell scripting language? I mean, that's basically what your Perl script is ...
If you wanted to write this in Perl, I'd do something like the following:
use strict; use warnings; my $app = 'nscd'; print "Looking for '$app'\n"; while (1) { open PS, "ps -ef |" || die "Cannot open ps command: $!\n"; my @cmd = grep { /$app/ } <PS>; close PS; last unless @cmd; print "'$app' is still running ...\n"; sleep 2; } print "'$app' is finished.\n";
------
We are the carpenters and bricklayers of the Information Age.
The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6
... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
|
|---|