Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7819417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:56:47+00:00 2026-06-02T06:56:47+00:00

I have this basic code that is failing: ftpconfighash = open(#{RAILS_ROOT}/config/ftp.yml) {|f| YAML.load(f) }

  • 0

I have this basic code that is failing:

  ftpconfighash = open("#{RAILS_ROOT}/config/ftp.yml") {|f| YAML.load(f) }
  config = ftpconfighash[12345]

  ftp = Net::FTP::new(config["host"])
  ftp.login(config["username"], config["password"])

  dir += "/" unless config["dir"].blank? or config["dir"].ends_with?("/")
  remotename = File.basename(filename)
  remotename = dir + remotename unless dir.blank?

  if File.binary?(filename)
    puts "PUTting binary file #{filename} to #{remotename}"
    ftp.putbinaryfile(filename, remotename)
  else
    puts "PUTting ASCII file #{filename} to #{remotename}"
    ftp.puttextfile(filename, remotename)
  end
  ftp.close

I have verified that I can ftp to the server and PUT a file by hand. I have also used irb to walk through the code line-by-line. I am using an XML file as a test, so the “ftp.puttextfile” is the line that is failing. Here is the error:

Net::FTPPermError: 500 Invalid PORT Command.

I don’t understand. I have verified that I can indeed put this file, but I just can’t do it with this code.

I set http://ftp.debug_mode to true, and this is the output from the http://ftp.puttextfile command:

put: TYPE A
get: 200 Type set to A.
put: PORT 10,0,1,20,198,170
get: 500 Invalid PORT Command.
Net::FTPPermError: 500 Invalid PORT Command.

from /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/net/ftp.rb:243:in `getresp'
from /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/net/ftp.rb:251:in `voidresp'
from /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/net/ftp.rb:274:in `voidcmd'
from /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/monitor.rb:242:in `synchronize'
from /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/net/ftp.rb:272:in `voidcmd'
from /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/net/ftp.rb:287:in `sendport'
from /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/net/ftp.rb:295:in `makeport'
from /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/net/ftp.rb:328:in `transfercmd'
from /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/net/ftp.rb:424:in `retrlines'
from /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/monitor.rb:242:in `synchronize'
from /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/net/ftp.rb:422:in `retrlines'
from /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/net/ftp.rb:631:in `list'
from (irb):42

It looks like Ruby is trying to run a command that the FTP server doesn’t understand:

PORT 10,0,1,20,198,170

Is there some way to suppress that command, or am I missing something else?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:56:48+00:00Added an answer on June 2, 2026 at 6:56 am

    Try using passive ftp:

    ftp = Net::FTP::new(config["host"])
    ftp.login(config["username"], config["password"])
    
    ftp.passive = true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have basic code that looks like this: while(inputfileStream.good()) { for(int i = 0;i<levels;i++)
So I have this page that has some basic custom tabs: http://demo.unlockedmanagement.com/users/view/2 * NOTE
I have a basic website nav layout that looks like this: <li class=folder parent_folder>
i have this code that should create a dialog with the page google inside
I have this Perl code that is only printing the first line instead of
I have some Visual Basic Code that creates a chart for each row. It
The basic code that I have so far is below. How do I thread
I have basic JavaScript code that needs to tell how many names out of
I have this basic auto complete JavaScript that works well, but you need to
hey, I have this code that should save a java.util.Vector of custom serializable classes:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.