onlineperluser has asked for the wisdom of the Perl Monks concerning the following question:
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: kill process when files created...
by jethro (Monsignor) on Jul 03, 2008 at 03:16 UTC | |
|
Re: kill process when files created...
by pc88mxer (Vicar) on Jul 03, 2008 at 03:40 UTC | |
by jethro (Monsignor) on Jul 03, 2008 at 04:47 UTC | |
by pc88mxer (Vicar) on Jul 03, 2008 at 05:25 UTC |