in reply to working with pid's

Of course if you want to invent the wheel again go ahead, but you got an excellent tool in the daemontools package by D. J. Bernstein that do just that, namely supervise. I use it myself on qmail and my halflife server ;o) If you want do do this in perl you may try something like this:
#!/usr/bin/perl -w open(PH, "ps -A|"); while (<PH>) { if (/q3ded/) { /\b(\d+)\b/; $pid = $1; } } print $pid;
It will at least return the pid, and you can do whatever you like with it.

Replies are listed 'Best First'.
RE: RE: working with pid's
by moen (Hermit) on Sep 18, 2000 at 17:41 UTC
    oopps..that was wrong code :) This is correct.
    Update!!: I just now saw that you also needed the names so, here's an edit.
    #!/usr/bin/perl -w use strict; my(%list); open(PH, "ps aux|"); while (<PH>) { if (/q3ded/) { /\b(\d+)\b.*:(.{3})(.*)/; $list{$1} = $3; } } close(PH); foreach (keys %list) { print $_, " ", $list{$_}, "\n"; }