another FTP modules problem

G

Greg Brondo

Here's the error I receive now (after Guy fixing my first issue):

c:/ruby/lib/ruby/1.8/net/ftp.rb:211:in `readline': End of file reached
(EOFError)
from c:/ruby/lib/ruby/1.8/net/ftp.rb:211:in `getline'
from c:/ruby/lib/ruby/1.8/net/ftp.rb:221:in `getmultiline'
from c:/ruby/lib/ruby/1.8/net/ftp.rb:235:in `getresp'
from c:/ruby/lib/ruby/1.8/net/ftp.rb:251:in `voidresp'
from c:/ruby/lib/ruby/1.8/net/ftp.rb:433:in `retrlines'
from c:/ruby/lib/ruby/1.8/net/ftp.rb:419:in `synchronize'
from c:/ruby/lib/ruby/1.8/net/ftp.rb:419:in `retrlines'
from c:/ruby/lib/ruby/1.8/net/ftp.rb:628:in `list'
... 6 levels...
from C:/src/ruby/chmod/ftp_chmod.rb:13:in `chmodFiles'
from C:/src/ruby/chmod/ftp_chmod.rb:35
from C:/src/ruby/chmod/ftp_chmod.rb:33:in `open'
from C:/src/ruby/chmod/ftp_chmod.rb:33

Dunno why I'm getting the EOF. Same basic logic works great in PHP and
Python. Any help would be greatly appreciated.

Here's the code:

require 'net/ftp'

def printInfo(msg)
puts Time.now.to_s + " :: #{msg}"
end

def chmodFiles(conn, dir)
conn.chdir(dir)
pwd = conn.pwd()
dirList = conn.list()
printInfo("file count = #{dirList.length}")
dirList.each() { |entry|
fileName = entry.split()[8]
if entry =~ /^d/ # It's a directory
printInfo(pwd)
chmodFiles(conn, fileName)
conn.chdir("..")
end
}
end

## Main
HOST = ARGV[0] || "localhost"
PERMISSIONS = ARGV[1] || "0775"
STARTDIR = ARGV[2] || "."

printInfo("Permissions = #{PERMISSIONS}")
printInfo("Start Dir = #{STARTDIR}")

Net::FTP.open(HOST) { |conn|
conn.login("blahuser", "blahpass")
chmodFiles(conn, STARTDIR)
}
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top