Obtaining statistics for Net::FTP transfers

By: Varghese Chacko 1 year, 3 months ago

With Net:FTP for uplink and downlink file transfers, we may have problems with obtaining the same statistics that are provided by ftp when you perform a manual transfer, i.e file size, transfer duration and transfer speed in KBs. The easiest solution is to print the $ftp->message;  It contain some message. For example,

#!/usr/bin/perl

use Net::FTP;

$ftp = Net::FTP->new("mysite.com", Debug => 0);
$ftp->login("myusr",'mypwd');
print $ftp->message,"\n";
$ftp->cwd("/pub");
print $ftp->message,"\n";
$ftp->get("myfile.pdf");
print $ftp->message,"\n";
$ftp->quit;

This will output

User myusr logged in.

CWD command successful

Opening ASCII mode data connection for myfile.pdf (10816217 bytes)
Transfer complete

Here we gets out put in bytes