Help! cannot recursive call

G

Greg Brondo

Having a problem with following code. It will drop to the first directory
and then hang. Any help will be appreciated.

---- snip ----
require 'net/ftp'

public

def chmodDir(ftp, dir)
ftp.chdir(dir)
puts ftp.pwd
ftp.list() do |e|
dir = e.split(/ +/)[8]
if e=~ /^d/
ftp.chmodDir(ftp, dir)
end
end
end

(site, user, pass, dir) = ARGV

ftp = Net::FTP.new(site, user, pass)

chmodDir(ftp, dir)

ftp.close()

---- snip ----

Thanks!

Greg B.
 
H

Harry Ohlsen

Greg said:
Having a problem with following code. It will drop to the first directory
and then hang. Any help will be appreciated.

---- snip ----
require 'net/ftp'

public

def chmodDir(ftp, dir)
ftp.chdir(dir)
puts ftp.pwd
ftp.list() do |e|
dir = e.split(/ +/)[8]
if e=~ /^d/
ftp.chmodDir(ftp, dir) # <-------------
end
end
end

Maybe I've misread the code, but shouldn't the marked line just be "chmodDir(ftp, dir)"?


H.
 
H

Harry Ohlsen

Harry said:
Maybe I've misread the code, but shouldn't the marked line just be
"chmodDir(ftp, dir)"?

Presumably, there should also be some kind of chmod() call in there, too. Ie, something like ...

def chmodDir(ftp, dir)
ftp.chdir(dir)
puts ftp.pwd
ftp.list() do |e|
dir = e.split(/ +/)[8]
if e=~ /^d/
ftp.chmod(dir) # <---------------- Change the subdirectory's mode
chmodDir(ftp, dir)# <---------------- Recurse to handle *its* subdirectories
end
end
end

But, maybe you're just trying to get the recursion working before adding that code. What's more, I don't even know whether there *is* a Net::FTP.chmod() method :). I'm just guessing here.

H.
 

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

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,126
Latest member
FastBurnketoIngredients
Top