Help! cannot recursive call

Discussion in 'Ruby' started by Greg Brondo, Jan 19, 2004.

  1. Greg Brondo

    Greg Brondo Guest

    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.
     
    Greg Brondo, Jan 19, 2004
    #1
    1. Advertising

  2. Greg Brondo

    Harry Ohlsen Guest

    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.
     
    Harry Ohlsen, Jan 19, 2004
    #2
    1. Advertising

  3. Greg Brondo

    Harry Ohlsen Guest

    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.
     
    Harry Ohlsen, Jan 19, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    480
    Alex Martelli
    Oct 18, 2004
  2. n00m
    Replies:
    12
    Views:
    1,123
  3. vamsi
    Replies:
    21
    Views:
    2,116
    Keith Thompson
    Mar 9, 2009
  4. Alok
    Replies:
    3
    Views:
    268
  5. Yohan N. Leder
    Replies:
    19
    Views:
    256
    Yohan N. Leder
    Jul 2, 2006
Loading...

Share This Page