#!/usr/bin/perl # # This script kills the pppd connection from /dev/ttyS # # Author: Laurentiu Cucos # Date : 03/11/02 #--- the parameter is the index of the port to kill --- $port = "ttyS$ARGV[0]"; unless($ARGV[0] == 0 or $ARGV[1] == 1){ die("Wrong argument! It must be either 0 or 1\n"); } #--- get the ps line with the id we want to kill $pppPS = `ps -e | egrep pppd | egrep $port`; $pppPS =~ s/ +//; #print "Found:$pppPS\n"; #--- get the ID only @arr = split(/ +/, $pppPS); $pppID = $arr[0]; if($pppID ne ""){ print "Kill pID: $pppID\n"; system("kill -9 $pppID"); }else{ print "No active connection on $port\n"; }