Size: how big is a file? Well, if you are downloading the file, you can use the Net::FTP->size() function. If you are uploading a file, you can use the stat function (type perldoc -f stat for more information).
Transfer duration: this shouldn't be too hard! Get the time (look at the time function) before you start the transfer, and subtract that from the time at the end of the transfer! Easy!
Transfer speed: quite simply is file size divided by transfer time. Again, so basic, I'm wondering why you asked this.. maybe you want this value in real time? If so.. refer to the module documentation again! There is an option to the ->New() function called Hash that will notify you every time 1024 bytes are transferred. Read about it!
Here's an example on how to get the size of files using Net::FTP (tested):
use Net::FTP; use strict; my $f = Net::FTP->new( Host => "cs.ucl.ac.uk", Firewall => "webproxy.local", FirewallType => 1, Passive => 1, ); $f->login( "anonymous", "myemail\@mycompany.com" ) or die( "Failed to log in to FTP server: " . $f->message ); my @list = $f->ls( '/rfc' ); foreach my $fname ( @list ) { my $size = $f->size( '/rfc/' . $fname ); defined( $size ) or die( " Failed to get size: " . $f->message ); print( " Size of $fname is $size\n" ); } $f->quit();
In reply to Re: Obtaining statistics for Net::FTP transfers
by monarch
in thread Obtaining statistics for Net::FTP transfers
by qragamu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |