Problem with Net::FTP.getbinaryfile

I am trying to write a simple script to retrieve all files that match a
certain filespec, e.g. as follows:

···

require ‘net/ftp’

#please forgive the following, can’t seem to connect to the Ruby site!
ftpConnection = Net::FTP.new(“ftp.python.org”)
ftpConnection.login(“anonymous”, nil)

ftpConnection.chdir("/pub/jython")

ftpConnection.list("*.tgz") {|fileInfo|

fInfo = fileInfo.split()

fileName = fInfo[8]
fileSize = fInfo[4].to_i

print "fetching ", fileName, ", ", fileSize, " bytes...\n"
ftpConnection.getbinaryfile(fileName, fileName)

}

ftpConnection.close

Things blow up in getbinaryfile-- I get the following:

fetching jython-faqw-08-Oct-2001.tgz, 47825 bytes…
D:/Development/Ruby-1.6.7/lib/ruby/1.6/net/ftp.rb:218:in `transfercmd’:
200 PORT
command successful. (Net::FTPReplyError)

    from D:/Development/Ruby-1.6.7/lib/ruby/1.6/net/ftp.rb:267:in 

retrbinary' from D:/Development/Ruby-1.6.7/lib/ruby/1.6/net/ftp.rb:266:inmon_synchronize’
from D:/Development/Ruby-1.6.7/lib/ruby/1.6/net/ftp.rb:266:in
retrbinary' from D:/Development/Ruby-1.6.7/lib/ruby/1.6/net/ftp.rb:358:ingetbinaryfile’
from E:\TEMP\gettgz.rb:17
from E:\TEMP\gettgz.rb:8:in call' from D:/Development/Ruby-1.6.7/lib/ruby/1.6/net/ftp.rb:295:inretrlines’
from D:/Development/Ruby-1.6.7/lib/ruby/1.6/net/ftp.rb:288:in loop' from D:/Development/Ruby-1.6.7/lib/ruby/1.6/net/ftp.rb:288:inretrlines’
from D:/Development/Ruby-1.6.7/lib/ruby/1.6/net/ftp.rb:285:in
mon_synchronize' from D:/Development/Ruby-1.6.7/lib/ruby/1.6/net/ftp.rb:285:inretrlines’
from D:/Development/Ruby-1.6.7/lib/ruby/1.6/net/ftp.rb:444:in `list’
from E:\TEMP\gettgz.rb:8

I am using ruby 1.6.7 (2002-03-01) [i586-mswin32] with Win2K Professional.

I saw a reference to a patch to Net::FTP in
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/42199 ,
but am uncertain as to how I would obtain it.

Many thanks.

Brian Young

ftpConnection.list("*.tgz") {|fileInfo|
    fInfo = fileInfo.split()
    fileName = fInfo[8]
    fileSize = fInfo[4].to_i
    print "fetching ", fileName, ", ", fileSize, " bytes...\n"
    ftpConnection.getbinaryfile(fileName, fileName)

The problem is here : you can't mix 2 FTP commands. You must first execute
#list then #getbinaryfile

}

Something like this

   list =
   ftpConnection.list("*.tgz") {|fileInfo|
      fInfo = fileInfo.split()
      fileName = fInfo[8]
      fileSize = fInfo[4].to_i
      list << [FileName, fileSize]
   }

   list.each {|FileName, fileSize|
      print "fetching ", fileName, ", ", fileSize, " bytes...\n"
      ftpConnection.getbinaryfile(fileName, fileName)
   }

Guy Decoux