| Category: | Utility |
| Author/Contact Info | Rohan Almeida |
| Description: | A perl script equivalent of the infamous zap from "Programming in the UNIX Environment" It accepts process names as arguments and then proceeds to zap(kill) them. |
#!/usr/bin/perl -w
# zap - kill processes by name
use strict;
my @pnames;
if ($#ARGV < 0) {
print STDERR "usage: $0 processname ...\n";
exit 1;
}
for (@ARGV) {
@pnames = `ps -C $_`;
kill 9, map { (split)[0] } @pnames[1 .. $#pnames];
}
|
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: zap in perl
by merlyn (Sage) on Mar 23, 2002 at 16:16 UTC | |
by arc_of_descent (Hermit) on Mar 23, 2002 at 16:33 UTC | |
|
Re: zap in perl
by Kanji (Parson) on Mar 23, 2002 at 16:29 UTC |