Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stopping a command within a script?

Status
Not open for further replies.

cab00se

Technical User
Oct 22, 2004
4
US
I'm new to perl, I'm trying to create a script that will capture tcpdump data into a specified file. So far i've been able to run the command just fine, however i don't know how to stop the process after a certain period of time. Say I want to capture 30 seconds of tcpdump data, how do I stop the tcpdump proccess after 30 seconds and continue with the script?

This is the first snippet of code i'm using to capture the data.

system ("/usr/sbin/tcpdump -npti eth0 > m2k.txt")
 
look into the -c flag which you can specify the number of sniffs

alternatively you could fork the process, and subsequently kill the relevant pid

HTH
--Paul

Nancy Griffith - songstress extraordinaire,
and composer of the snipers anthem "From a distance ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top