If I execute this locally, everything works fine:
require 'net/ftp'
ftp=Net::FTP.new("myftpserver.com", "username", "password")
ftp.getbinaryfile("/myfile.zip","localfile.zip")
ftp.close
If I attempt to execute it on the Linux server I am using, the result is:
/usr/local/lib/ruby/1.9.1/net/ftp.rb:273:in `getresp': 500 Illegal
PORT command. (Net::FTPPermError) from
/usr/local/lib/ruby/1.9.1/net/ftp.rb:281:in `voidresp' from
/usr/local/lib/ruby/1.9.1/net/ftp.rb:304:in `block in voidcmd' from
/usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' from
/usr/local/lib/ruby/1.9.1/net/ftp.rb:302:in `voidcmd' from
/usr/local/lib/ruby/1.9.1/net/ftp.rb:317:in `sendport' from
/usr/local/lib/ruby/1.9.1/net/ftp.rb:325:in `makeport' from
/usr/local/lib/ruby/1.9.1/net/ftp.rb:358:in `transfercmd' from
/usr/local/lib/ruby/1.9.1/net/ftp.rb:420:in `block (2 levels) in
retrbinary' from /usr/local/lib/ruby/1.9.1/net/ftp.rb:166:in
`with_binary' from /usr/local/lib/ruby/1.9.1/net/ftp.rb:419:in `block
in retrbinary' from /usr/local/lib/ruby/1.9.1/monitor.rb:201:in
`mon_synchronize' from /usr/local/lib/ruby/1.9.1/net/ftp.rb:418:in
`retrbinary' from /usr/local/lib/ruby/1.9.1/net/ftp.rb:539:in
`getbinaryfile'
What could be the problem?
The connection is set to be in passive mode. Show activity on this post. If you get "500 Illegal PORT command.", you are using the active mode, not the passive mode. Double check that and make sure to really use the passive mode. ftp_get: Illegal PORT command.
ftplib.error_perm: 500 Illegal PORT command. ftplib.error_perm: 550 Illegal PORT command. Probably the file is no longer avaible on the FTP server? Since that from my local machine works well I was thinking that it could be a problem with docker. This is the code which triggers the copy: And this is the move_file function:
Click "Control Panel". Click on "Network and Internet". Click on "Windows Firewall". Click on "Change Setting". Under that tab, put a check mark next to the FTP port 21. This should allow connections to FTP sites. Click "OK" on the Firewall settings and close the other windows. Restart your computer and try to connect to the FTP site again.
Re-try the FTP link. If this does not work, you maybe completely firewalled/prevented from accessing FTP sites. In this case an alternative download method will be needed i.e. HTTP/web link.
I found the answer at http://www.ruby-forum.com/topic/161274:
Beyond firewalls, active ftp won't work behind a NAT device. Ftp servers sometimes say illegal port command if you tell them that your address is a private ip address like 192.168.x (your address on the network behind the nat device)
Adding:
ftp.passive = true
fixed it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With