Net/ftp issue

Hi,

I am having problem with the 'net/ftp' library (ruby 1.8.2 (2004-08-24)
[i386-linux]).
If I make a simple call to FTP#mtime method, the following error occurs:

/usr/lib/ruby/1.8/net/ftp.rb:700:in `mtime': private method `scan' called for
nil:NilClass (NoMethodError)

which means that FTP#mdtm method returns nil.
In fact, only the very first call to FTP#mdtm returns nil!

The following script should reproduce the error :

require 'net/ftp'

$, = ' '
$\ = "\n"

Net::FTP.open('ftp.ruby-lang.org') do |ftp|
  ftp.login
  ftp.chdir('pub/ruby/stable')
  ftp.list('*') do |line|
    # p line
    if line =~ /^[-d]/
      fileName = line.split[-1]
      isFile = line[0] == ?-
      print 'entry:', fileName, isFile ? 'is a file' : 'is a directory'
      if isFile
        # print 'mdtm:', ftp.mdtm(fileName) # <-- if commented, fails
        print 'mtime:', ftp.mtime(fileName)
      end
    end
  end
end

I guess it's not related to 'net/ftp' library!
But could you confirm?

Best Regards,
Bart.

Try it with

Net::FTP.open('ftp.ruby-lang.org') do |ftp|
  ftp.login
  ftp.chdir('pub/ruby/stable')
  ftp.list('*') do |line|

     ftp.list('*').each do |line|

    # p line
    if line =~ /^[-d]/

Guy Decoux

Shame on me!
And thank you for replying.

Quoting ts <decoux@moulon.inra.fr>:

···

Try it with

> Net::FTP.open('ftp.ruby-lang.org') do |ftp|
> ftp.login
> ftp.chdir('pub/ruby/stable')
> ftp.list('*') do |line|

     ftp.list('*').each do |line|

> # p line
> if line =~ /^[-d]/

Guy Decoux