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

I am doing some large file transfers between machines using Net::FTP. I would like to be able to monitor the progress of said transfers and give the user some feedback. Is there functionality in Net::FTP to do this?

Item of note: On win32 using ActivePerl 5.10. It appears that Net::FTP plays nice with threads (I've been playing around with them), but when I try to introduce threading in with my Tkx code, it bombs wickedly.

Replies are listed 'Best First'.
Re: Monitor transfers with Net::FTP
by derby (Abbot) on Aug 17, 2009 at 17:19 UTC

    Check out the Hash attribute (and hash method) in Net::FTP.

    -derby
      How do you implement this to where the transfer doesn't just stop the script as it does it?

      Since I'm on win32 I can't do a fork, and running in a separate thread seems to cause problems when the thread gets returned, crashing wickedly.

      EG:

      while ($ftp->put($file)) { warn "Still putting data!\n"; $ftp->hash("", 1); }

      Doesn't work as expected, printing hashes on stdout during the transfer.

        That's not how you invoke it. Either make your constructor like such:

        my $ftp = Net::FTP->new( "some.host.name", Hash => 1);
        Or before you call put call the hash method:
        $ftp->hash( 1 );

        -derby
Re: Monitor transfers with Net::FTP
by tokpela (Chaplain) on Aug 17, 2009 at 18:26 UTC

    Great tip on the hash function, derby.

    I just wanted to add when looking up the hash function, I ran across the Net::FTP::Robust module that is specifically made for large downloads. It uses Net::FTP (so you can still use the hash function) but also gives additional logging and error trapping.

      Robust does sound like a nice utility, but I'm putting the file, not getting it.