|laziness, impatience, and hubris|
Re: Net::FTP Unexpected EOFby rob_au (Abbot)
|on Jan 10, 2002 at 09:33 UTC||Need Help??|
Your problem here resides not so much with your script but with your network configuration and specifics of the FTP protocol.
When connecting to a FTP server, two socket streams are used for communications - The first is the control connection initiated by your FTP client between which the FTP client and server exchange commands and replies (TCP socket 21). The second is a full-duplex connection over which data is transferred in a specified mode and type. The data transferred may be part of a file, an entire file or a listing of files within a directory. Typically, this data port is the port adjacent to the control port (TCP socket 20).
In general, it is the FTP server's responsibility to initiate and maintain the data connection. It is here that your script is running into problems.
According to the output supplied, it appears you are attempting to connect to the FTP from a machine with a private class address of 10.1.4.49 - This host address, along with the preferred socket for data communications, are sent to the server via the PORT command. I suspect that you are in fact connecting to a live Internet host with this script through a network firewall or layer of address translation and as such, the data connection from the server to your machine is failing because the FTP server is unable to reach your private machine.
The means by which to fix this is to switch to passive FTP transfer mode via the PASV command - This command changes the default behaviour of data port negotiation, shifting the onus for responsibility for data port establishment and maintenance back to the client. This allows the client to control its only data connection through the network firewall or translation layer, allowing normal FTP communications to occur. eg.
Further information on this topic can be found in RFC documents (0959) File Transfer Protocol, (1122) Requirements for Internet hosts - communication layers and (1579) Firewall-Friendly FTP.
perl -e 'firstname.lastname@example.org&&&split/[@.]/&&s&.com.&_&&&print'