Hi,

I am having problem with Ruby standard lib net/ftp .

require 'net/ftp'
 
ftp = Net::FTP.new('ftp.ruby-lang.org')
ftp.login
ftp.passive = true
files = ftp.chdir('/pub/ruby/')

ftp.list do |l|
  if l.start_with?('d')
    dir_name = l.split(" ").last
    p ftp.nlst "#{dir_name}/*.tar.bz2"
  end
End

If I run the above code, getting below error :

[arup / Ruby]$ ruby a.rb
/home/arup/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/ftp.rb:974:in `parse227': 226 Directory send OK. (Net::FTPReplyError)

And If I modified as below :

require 'net/ftp'
 
ftp = Net::FTP.new('ftp.ruby-lang.org')
ftp.login
files = ftp.chdir('/pub/ruby/')

ftp.list do |l|
  if l.start_with?('d')
    dir_name = l.split(" ").last
    p ftp.nlst "#{dir_name}/*.tar.bz2"
  end
End

And run it again, then getting error as :

[arup / Ruby]$ ruby a.rb
/home/arup/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/ftp.rb:324:in `getresp': 425 Failed to establish connection. (Net::FTPTempError)


How to fix it ?

-- 
================
Regards,
Arup Rakshit
================
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

--Brian Kernighan