For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > March 2004 > getting realtime progress output from rsync









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author getting realtime progress output from rsync
perl coder

2004-03-27, 12:01 am

I'm trying to figure out how to retrieve status output from an rsync
command ("rsync --progress"). The --progress option shows a percentage
of the file transfered and estimated ETA, on one line. But since rsync
overwrite the status line each time with the current info (instead of
going to the next line), I can't use stdio to retrieve it. Well, I
can, but I'll only get the final write, which pretty much defeats my
purpose.

I also can't use select because this must work on win98. :-( And from
what I've seen from browsing google, Expect and IO::Pty don't work on
the win32 platform.

That doesn't seem to leave many options. In fact, I have only one idea
right now, but it's inefficient as hell:

system("rsync --progress ${host}::$user/$file . </dev/null >log 2>&1");

# $ ./r.pl &
# [1] 2049
# $ cat log
# 1245184 11% 1.01MB/s 0:00:08
# $ cat log
# 3604480 34% 1.06MB/s 0:00:06
# $ cat log
# 5963776 57% 1.07MB/s 0:00:04
# $ cat log
# 6815744 65% 920.61kB/s 0:00:03
# $ cat log
# 8585216 82% 953.70kB/s 0:00:01
# $ cat log
# 10059776 96% 973.35kB/s 0:00:00
# [1]+ Done ./r.pl
# $ cat log
# 10442514 100% 980.37kB/s 0:00:10

In other words: redirect rsync output to a file, and read it at regular
intervals. But this is kinda kludgy, and just makes rsync hog even more
I/O...

Anyone got a better idea?


--
No crazy stuff in my email. ;-)
Anno Siegel

2004-03-27, 12:01 am

perl coder <perlcdr@mail.rumania> wrote in comp.lang.perl.misc:
> I'm trying to figure out how to retrieve status output from an rsync
> command ("rsync --progress"). The --progress option shows a percentage
> of the file transfered and estimated ETA, on one line. But since rsync
> overwrite the status line each time with the current info (instead of
> going to the next line), I can't use stdio to retrieve it. Well, I
> can, but I'll only get the final write, which pretty much defeats my
> purpose.


You only *see* the final write, you get them all. The messages are
separated by carriage returns ("\r"), not by line feeds ("\n").
Set local $/ accordingly, and read the program's STDOUT or STDERR,
whichever (untested).

[snip]

Anno
perl coder

2004-03-27, 12:01 am

Anno Siegel said:
> You only *see* the final write, you get them all. The messages are
> separated by carriage returns ("\r"), not by line feeds ("\n").
> Set local $/ accordingly, and read the program's STDOUT or STDERR,
> whichever (untested).


Hey that works great! And so simple too. Thank you!


--
No crazy stuff in my email. ;-)
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com