Hi, I don't know how it is done on Windows, but I suspect you need to turn off buffering of STDOUT to get immediate readout. Try using $|=1 to turn off STDOUT buffering. Also see
Is print faster than syswrite? and
Re^3: explanation for sysread and syswrite for examples on using syswrite and sysread. If you write your own copying program with syswrite and turn stdout buffering off, you should be able to monitor your instantaneous progress. Look at this example from the perlmonks archives:
#!/usr/bin/perl -w
use strict;
use IPC::Open2;
use IO::Select;
$| = 1; # autoflush STDOUT
# Declare filehandles and command to use:
my ($r, $w);
my $cmd = 'ping 127.0.0.1';
# Open the process and set the selector:
my $pid = open2($r, $w, $cmd);
my $selector = IO::Select->new($r);
while (1) # infinite loop (use "last" to break out)
{
if ($selector->can_read(0))
{
my $chars;
my $bytes_read = sysread($r, $chars, 4046);
print "$bytes_read $chars\n";
}
# Do anything you want in between reads here...
}
__END__
The advantage to this script is that, if your commands (like
"whois", "dig", and "ping") happen to pause, the loop won't
automatically break out. The disadvantage to this script is that it
might be difficult figuring out when a command has finished, or just
has delayed output (in which case you might have to put in a few
sleep() calls). Either way, I think that this script here does a
better job of helping you visualize what is going on -- you just need
to be mindful of the fact that some programs don't flush their output
right away, and that it's not a simple matter to tell if the program
has stopped running altogether.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.