in reply to Killer
Using /bin/grep, awk, and /bin/kill inside Perl! Blasphemy!!! Friar, where is the hot oil?? ;)
#!/usr/bin/perl -w use strict; die "Usage: $0 regex\n" unless 1 == @ARGV; for my $proc ( map {(split(' '))[1]} grep /$ARGV[0]/, `ps -ef` ) { if( ! kill(-9,$proc) ) { warn "Can't kill PID $proc: $!\n"; } else { print "Killed PID $proc.\n"; } }
And that still leaves much room for improvement (and I didn't test this either, sorry).
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: RE: Killer
by merlyn (Sage) on Aug 05, 2000 at 01:51 UTC | |
by tye (Sage) on Aug 05, 2000 at 08:42 UTC | |
by cybear (Monk) on Jun 09, 2002 at 03:46 UTC |