-->

Obtaining statistics for Net::FTP transfers

By: Varghese Chacko 1 year, 5 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

Wish to hire us?

We take the vision which comes from dreams and apply the magic of science and mathematics, adding the heritage of our profession and our knowledge to create a design.