net/ftp issue

E

elbart0

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.
 
T

ts

Try it with

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

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

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



Guy Decoux
 
E

elbart0

Shame on me!
And thank you for replying.

Quoting ts said:
Try it with

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

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

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



Guy Decoux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top