Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

monitoring upload progress in Net::FTP

by peterg22 (Novice)
on Jan 10, 2002 at 20:42 UTC ( [id://137755]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://137755]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-23 16:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found