Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Help! cannot recursive call

Reply
Thread Tools

Help! cannot recursive call

 
 
Greg Brondo
Guest
Posts: n/a
 
      01-19-2004
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.


 
Reply With Quote
 
 
 
 
Harry Ohlsen
Guest
Posts: n/a
 
      01-19-2004
Greg Brondo wrote:

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



 
Reply With Quote
 
 
 
 
Harry Ohlsen
Guest
Posts: n/a
 
      01-19-2004
Harry Ohlsen wrote:
> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recursive functions Vs Non-recursive functions - performance aspect vamsi C Programming 21 03-09-2009 10:53 PM
Two recursive calls inside of a recursive function n00m C++ 12 03-13-2008 03:18 PM
Does recursive call able to print in same page as main call Yohan N. Leder Perl Misc 19 07-02-2006 11:45 AM
defined? for recursive function call v/s defined? for function call stack Alok Ruby 3 04-13-2006 11:53 AM
Why is function call - recursive especially - in python so slow? iviskic@uci.edu Python 1 10-18-2004 08:37 PM



Advertisments