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 "$_"; }

In reply to Autoflush fails by sophate

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.