I am trying to run a tcpdump and have perl kill the tcpdump once 10 files have been created by the tcpdump. Here is my code, not sure of my logic.
Thanks,#!/bin/perl system "tcpdump -i bge1 -s0 -w /tmp/file.out -C 1"; sleep 2; while(true){ <pre>@array1 = `ls -l /tmp | grep files`; $result=@array1+1; if ($result > 3){ $x=`ps -ef | awk '/tcpdump/ && !/awk/ {print $ +2}'`; @y=split(' ', $x); $c=$y[1]; system "kill -9 $c"; print "killing tcpdump..."; }else{ print "!!!\n"; exit; } exit; }
In reply to kill process when files created... by onlineperluser
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |