in reply to FTP Transfer Status

According to the documentation:

Hash - If given a reference to a file handle (e.g., "\*STDERR"), print + hash marks (#) on that filehandle every 1024 bytes.

Maybe you could use this to gather progress?

Update:Net::FTP is writen in OO-style. Maybe you could write your own subclass, and simply inherit from Net::FTP? Implement your own get() method that reports back the transfer progress you need.

Update:Looks like you don't even need to do that.. instead of calling the get() method, you can call retr() directly, and handle all the file reading/writing yourself.

Replies are listed 'Best First'.
Re: Re: FTP Transfer Status
by pg (Canon) on Mar 11, 2003 at 03:24 UTC
    We have a little bit misunderstanding of retr() here ;-), and retr() absolutely does not provide you the kind of control you are looking for, over file transfer.

    FTP involves two TCP connections, control connection and data connection. When you do things such like LIST etc., the control connection is used. When you do get() or retr(), the data connection is used.

    For the control connection, it is always the FTP server listens for TCP connection, and your client connects to the server.

    For the data connection, there are two modes:
    1. active mode (default). In this mode, the FTP client (your script) listens for TCP connection, and the FTP server side connects to you.
    2. passive mode. In this mode, the FTP server listens for TCP connection, and your client script connects to the server.
    Internally, both get() and retr() resolve to the same FTP command "RETR", but before retr(), the two sides of FTP would negotiate and go to passive mode. In both mode, Net::FTP has full control of socket reading and writing, not your script.

    There is no way Net::FTP can provide what allyc wants. To subclass Net::FTP sounds reasonable.