Salut Dario,
Je détéste envoyer un message et d'oublier d'attacher le fichier!
Voila donc grepk dont je te parlai.
Ivan
Linux-Azur : http://www.linux-azur.org
Désinscriptions: http://www.linux-azur.org/liste.php3
**** Pas de message au format HTML, SVP ****
#!/usr/bin/perl -w
# Kill all programs that matched with the given string
if (! @ARGV) {
die "grepk needs an argument to grep for!\n"
}
open (PS, "ps -eo pid,comm |");
while (<PS>) {
if (m/@ARGV/) {
printf;
@words = split;
@pid = (@pid, $words[0]);
}
}
close (PS);
if (@pid) {
if (@pid > 1) {
$plural = "es";
} else {
$plural = "";
}
printf "Do you wish to kill the above process$plural [Y/n]";
$answer = <STDIN>;
chomp ($answer);
if ($answer eq "" || $answer eq "y") {
kill (9, @pid)
}
}