in reply to Retrieving the Progress of a Command
The code to differentiate between a filename and a progress line could be upgraded a bit but this is the general approach I would use to monitor progress bars.use feature qw(say); my $rsync_command = 'rsync ... --progress'; open my $RSYNC, '-|', $rsync_command or die "Failed to start rsync: $! +"; local $/ = "\r"; while (<$RSYNC>) { if (/\A\s/) { # progress lines start with whitespace say 'Progress: ', $_; } else { print 'File: ', $_; # file lines have newlines at the end } } close $RSYNC;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Retrieving the Progress of a Command
by hoyt (Acolyte) on Sep 13, 2016 at 22:39 UTC |