vendion has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks, I am trying to use Net::SFTP to grab a couple of files off a remote server and show the progress in percent downloaded, but what my script displays is incorrect.
Here is basically what I am trying to due:
#!/usr/bin/perl use strict; use warnings; use Net::SFTP; my %args = ( user => 'me', password => 'xxxxxxxxxx' ); my $sftp = Net::SFTP->new( 'ftp.example.com', %args ) || die 'Could no +t connect to the server: ' . $! . "\n"; $sftp->get( 'file1.txt', 'file1.txt', \&callback ) || die 'Could not f +etch remote file: ' . $! . "\n"; sub callback { my ( $sftp, $data, $offset, $size ) = @_; my $percent = ($offset/$size)*100; print $percent . ' '; return; }
The output of the print is:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange math issue with Net::SFTP (Pari)
by tye (Sage) on May 29, 2012 at 16:36 UTC | |
by vendion (Scribe) on May 29, 2012 at 16:59 UTC | |
by vendion (Scribe) on May 29, 2012 at 17:40 UTC | |
|
Re: Strange math issue with Net::SFTP
by salva (Canon) on May 29, 2012 at 18:36 UTC | |
|
Re: Strange math issue with Net::SFTP
by toolic (Bishop) on May 29, 2012 at 15:23 UTC | |
by vendion (Scribe) on May 29, 2012 at 16:54 UTC | |
by toolic (Bishop) on May 29, 2012 at 17:03 UTC | |
by vendion (Scribe) on May 29, 2012 at 17:30 UTC | |
|
Re: Strange math issue with Net::SFTP
by zentara (Cardinal) on May 29, 2012 at 20:34 UTC |