I have a perl script that basically moves directories from one server to another. In it is a line using rsync that does this:
my $rsync_command = 'rsync -vrlte "ssh -p '.$pref_values->{'SSH_PORT'} +.' -l '.$pref_values->{'SSH_USER'}.' -o StrictHostKeyChecking=no" --p +rogress'; my $cmd = `$rsync_command "$full_dir_name"/* $pref_values->{'SSH_SERVE +R'}:$home_dir_name`;
I'm moving some large directories over the internet, so oftentimes this command takes 20 or 30 minutes. I'd like to somehow grab the output of the rsync command and update a database with the progress. Right now, I'm only adding a line that says started, and a line that says done. On occasion the script crashes, or the connection is interrupted, etc. So when I see Started, I have to log into the target server and check the directory size to see if it's still growing. The output of this command when I run it manually looks like this:
File1 1,282 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=23/24) File2 1,064 100% 346.35kB/s 0:00:00 (xfr#2, to-chk=22/24) File3 3,506,176 10% 121.86kB/s 0:04:17 ^C
Is there anyway to poll this command and get the output while it's running? I know I can grab it at the end and insert a summary, but I want to be able to look in my database and see that I'm 10% of the way through File3, it's going at 121 kB/s and there's 4:17 left on that file. Thanks!

In reply to Retrieving the Progress of a Command by hoyt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.