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.