peterg22 has asked for the wisdom of the Perl Monks concerning the following question:

Folks, I am doing a bog-standard file upload using Net::FTP, like so:

$ftp->put($ZipFile,$TargetZip);

Problem is, I don't know how to monitor the upload progress, or lack of it, as once the PUT starts, nothing is displayed until completion. I know I could switch debug on, but this would make the users panic.. Any suggestions would be most welcome..

Replies are listed 'Best First'.
Re: monitoring upload progress in Net::FTP
by derby (Abbot) on Jan 10, 2002 at 21:04 UTC
    peterg22,

    You can use Net::FTP's hash method to output a '#' to a particular filehandle for every x number of bytes (1024 default). For example:

    $ftp->hash( \*STDERR); $ftp->put($ZipFile, $TargetZip);

    Should do the trick. Sure it's not pretty but it is a good visual clue that somethings going on. perldoc Net::FTP for more info.

    -derby

      Aha!

      Can't locate auto/Net/FTP/hash.al in @INC...

      I remember now why I didn't go down this route.. time to go and hassle the SysAdmins to get a later version.. Thanks for the rapid replies!

Re: monitoring upload progress in Net::FTP
by hatter (Pilgrim) on Jan 10, 2002 at 21:11 UTC
    According to its manpage, you can enable 'hash' in Net::FTP and then just count them as they arrive, to give the amount of data transfered, or get the file size prior to transfer and divide them to get a percentage.

    the hatter