# $IP will have the actual ip from where packets are coming in system(" tcpdump -v -i eth1 dst $IP > file.txt & "); my $GREP=`ps aux | grep 'tcpdump ' | grep -v grep | awk '{print \$2}'`; chomp($GREP); print "PID for |$IP| IS -->|$GREP|\n"; print "SLEEEPING FOR 5 seconds....\n"; sleep(5); chomp($GREP); print "KILLING PROCESS ID ------->|$GREP|\n"; system("kill -9 $GREP"); my $LINES=`wc -l $path\/file.txt | awk '{ print \$1}'`; chomp($LINES); if($LINES > 5) { # I have ip coming in } else { # Looks like ip with udp packets is not coming in } }