in reply to Re: capture output of tcpdump and PID
in thread capture output of tcpdump and PID

Thanks, i also tried another way to stop the process, and it's quite simple... i just close(LABEL)

I also tried the alarm code, and it works

The alarm code isn't somehow similar to this:

open (CAPTURE,"sudo /usr/sbin/tcpdump -i wlan0 |"); $startTime = time(); while ( $line = <CAPTURE> ) { ### some code $endTime = time(); $t = $endTime - $startTime; if($t>10) { close(CAPTURE); last; } }

how could i pause at regular intervals the tcpdump process to switch between wifi channels 1, 6, 11 without stopping (closing) the pipe ?

Any idea would be appreciated

Replies are listed 'Best First'.
Re^3: capture output of tcpdump and PID
by aaron_baugher (Curate) on May 24, 2012 at 18:29 UTC

    How do you set/change the channel? If you do it by giving tcpdump an argument, then I suspect you're out of luck. You'll just have to stop the process and restart it with the new channel setting. If the channel can be changed with some other utility while tcpdump is running, then it should be fairly simple: read from the pipe until you want to change it (maybe based on how much time has elapsed since you started), and then run the other utility, then continue reading from the pipe. There may be some buffered output from tcpdump already waiting at the moment you change the channel. If that's a problem, you may have to do something more fancy.

    Aaron B.
    Available for small or large Perl jobs; see my home node.

Re^3: capture output of tcpdump and PID
by thargas (Deacon) on May 25, 2012 at 11:30 UTC
    The problem with just adding the time-comparison to the loop is that if nothing comes from tcpdump, the loop hangs waiting for something and your timeout code is never invokes. At least not until after something does come in. Perhaps this is not an issue in your case.