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

Hi,

I've got a bit of a weird issue here!

With the following code:

my $ftps = Net::FTPSSL->new('mysite.org', Port => 21, Encryption => 'E', Debug => 0, Timeout => 3600) or die "Can't open FTP"; $ftps->login("xxxxx",'xxxx') or die "Cannot login ", $ftps->message; $ftps->binary(); $ftps->cwd("/public_html/cgi-bin/links/admin/IMPORT") or die "Cannot c +hange working directory ", $ftps->message; print "Currently in: " . $ftps->pwd(). "\n"; $ftps->put("/home/user/public_html/cgi-bin/hotels/admin/com.csv") or d +ie "Cannot upload ", $ftps->message;
I then get this error:

Cannot upload 555 Unexpected EOF on Command Channel [0] (0, 1) () at export-csv-other-sites.cgi line 284.


Line 284 is:

$ftps->put("/home/user/public_html/cgi-bin/hotels/admin/com.csv") or die "Cannot upload ", $ftps->message;

I've updated to the latest version of Net::FTPSSL, but the problem still exists.

Any ideas? :)

Thanks

Andy

Replies are listed 'Best First'.
Re: Weird Net::FTPSSL error
by stevieb (Canon) on Apr 09, 2016 at 12:12 UTC

    This is almost always caused by NAT issues with the control channel (which Passive Mode gets around, which is default in Net::FTPSSL), or the FTP server itself is replying back with an incorrect passive mode IP address.

    In your new() constructor, try setting OverridePASV => x.x.x.x, where x.x.x.x is the same as the IP you connect initially to.

    If that doesn't work, fire up tcpdump or Wireshark and have a look at what traffic you see when you attempt to connect. Post the results of that back here if you don't understand them.

      Thanks for the reply. Tried that, but to no avail :( I just get:

      connect: Connection refused at /usr/lib/x86_64-linux-gnu/perl5/5.20/Net/SSLeay/Handle.pm line 229.


      I did a bit more research, and found out I can do it via Curl:

      curl -T /home/user/public_html/cgi-bin/hotels/admin/com_spots.csv ftp://dest-server.org/public_html/cgi-bin/links/admin/IMPORT/ --user user:pass

      Tested that out, and works a treat :)

      Thanks for trying to help though!

      Cheers

      Andy

        So you aren't using FTP over SSL/TLS after all (there are no SSL/TLS options in your curl usage). If you still want to use Perl then switch to Net::FTP.