steved has asked for the wisdom of the Perl Monks concerning the following question:
When using Net::FTP to list remote ftp directories. The FTP module returns an object undefined in Net::Cmd if the remote directory is empty. This seems to happen with some servers and not others.
What I've found is that when executing an ls() on an empty directory, some servers will return a 250 status code indicating that a non terminal error has occured. This is fine. Some "other servers" will return a 500 status error which seems to cause the Net::Cmd to disconnect the session and undef the object leaving the caller to catch it in an eval.
I believe that the servers should return 2x0 regardless of the connection type as it's not a fatal error.
The "other servers" behave differently depending on whether the connection is passive or non-passive. Under a passive connection I got a 500 and crashed but when connecting non-passively the same "other server" returned a 250 as expected.
What made it hard to find was that I was not implicitly setting a passive connection and the scripts behaviour was changing between the dev and production environments. The answer has been to implicitly set the PASSIVE parameter in the script and never to assume that the default is consistent.
|
|---|