intranetman has asked for the wisdom of the Perl Monks concerning the following question:
I've tried using gmtime but it still continues reading even when it reaches a set time. Should I make the tcpdump a thread and then kill that thread after a specific time? Any comments/suggestions would be great. Thanks.open (fileOUT, ">> /results.out") or dienice ("Can't open file for wr +iting"); close(fileOUT); open (STDIN,"/usr/sbin/tcpdump -lnx -s 1024 dst port 80 |"); while (<>) { if (/^\S/) { last unless $LIMIT--; while ($packet=~/(GET|POST|WWW-Authenticate|Authorization).+/g) + { open (fileOUT, ">> /results.out") or dienice ("Can't open fi +le for writing"); flock(fileOUT, 2); seek(fileOUT, 0, 2); print fileOUT "$client -> $host\t$&\n"; close(fileOUT); } undef $client; undef $host; undef $packet; ($client,$host) = /(\d+\.\d+\.\d+\.\d+).+ > (\d+\.\d+\.\d+\.\d+) +/ if /P \d+:\d+\((\d+)\)/ && $1 > 0; } next unless $client && $host; s/\s+//; s/([0-9a-f]{2})\s?/chr(hex($1))/eg; tr/\x1F-\x7E\r\n//cd; $packet .= $_; }
2004-11-22 Edited by Arunbear: Changed title from 'tcpdump', as per Monastery guidelines
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: tcpdump: setting a conditional timeout
by merlyn (Sage) on Nov 19, 2004 at 18:40 UTC | |
by Fletch (Bishop) on Nov 19, 2004 at 19:32 UTC | |
|
Re: tcpdump: setting a conditional timeout
by kappa (Chaplain) on Nov 19, 2004 at 18:49 UTC | |
|
Re: tcpdump: setting a conditional timeout
by Anonymous Monk on Nov 20, 2004 at 06:30 UTC |