in reply to parsing rsync output
You've got a buffering problem. One option would be to set $/ to a reference to an integer, which will cause perl to give you a chunk of that many bytes on each read, rather than reading a line at a time. If you do this though, you then have to deal with assembling the records into lines yourself. Something like this should work...
open ( CORE, "/usr/bin/rsync $rsyncOPT --progress $outbox $inbox |" ); local $/ = \128; # read 128 bytes at a time my $buffer = ''; while( <CORE> ) { $buffer .= $_; while ( $buffer =~ s/^(.*?)[\r\n]// ) { local $_ = $1; # code } }
Another (possibly better) option would be to use Expect, which is designed for this type of application...
| We're not surrounded, we're in a target-rich environment! |
|---|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: parsing rsync output
by Anonymous Monk on Nov 22, 2007 at 18:13 UTC |