Professional Web Applications Themes

Help! cannot recursive call - Ruby

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

  1. #1

    Default Help! cannot recursive call

    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 Guest

  2. #2

    Default Re: Help! cannot recursive call

    Greg Brondo wrote:
     

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


    H.



    Harry Guest

  3. #3

    Default Re: Help! cannot recursive call

    On Mon, Jan 19, 2004 at 11:24:11PM +0000, Greg Brondo wrote: 

    That should be just chmodDir(ftp, dir), no "ftp.". "ftp.chmodDir" tries
    to call the method chmodDir() on the Net::FTP object, which doesn't
    exist.

    You could change your code to define it as a method of class Net::FTP
    if tha'ts what you want, in which case it would be ftp.chmodDir(dir),
    but otherwise just lose the "ftp." so you call your own function
    recursively.

    -Mark
    Mark Guest

  4. #4

    Default Re: Help! cannot recursive call

    Harry Ohlsen wrote: 

    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 Guest

Similar Threads

  1. Recursive call with session variable
    By sheldonlg in forum Dreamweaver AppDev
    Replies: 1
    Last Post: May 23rd, 01:52 AM
  2. #26306 [Bgs]: Recursive function call crashes engine
    By toolshed51 at yahoo dot com in forum PHP Development
    Replies: 0
    Last Post: November 21st, 06:20 PM
  3. #26306 [NEW]: Recursive function call crashes engine
    By toolshed51 at yahoo dot com in forum PHP Development
    Replies: 0
    Last Post: November 18th, 07:25 PM
  4. remote call procedure call failed
    By Dave Warwick in forum Windows Networking
    Replies: 0
    Last Post: July 5th, 03:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139