May I suggest some ways to approach your problems. Firstly, have a good read of the Net::FTP documentation.

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

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.