sophate has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I'm struggling with autoflush in a Perl program that needs to catch the results of tcpdump running as root. The codes are as shown below. Though I set autoflush of the file handle, TCPDump, to true, it doens't seem working. Really appreciate if any monks can shred some light on this. Many thanks.
#!/usr/bin/perl -w use strict; use warnings; use IO::Handle; my ($Interface, $Multicast, $Port) = ('eth3', '226.1.109.109', '12345' +); open (TCPDump,"sudo /usr/sbin/tcpdump -i $Interface host $Multicast 2> +/dev/null |") || die "Can't open tcpdump : $!"; TCPDump->autoflush(1); while (<TCPDump>) { print "$_"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Autoflush fails
by Anonymous Monk on May 31, 2012 at 03:39 UTC | |
by sophate (Beadle) on May 31, 2012 at 03:50 UTC | |
by Anonymous Monk on May 31, 2012 at 04:09 UTC | |
by sophate (Beadle) on May 31, 2012 at 04:23 UTC | |
by Anonymous Monk on May 31, 2012 at 05:31 UTC | |
|
Re: Autoflush fails
by NetWallah (Canon) on May 31, 2012 at 05:23 UTC | |
by sophate (Beadle) on May 31, 2012 at 10:03 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |