From: Ezra Zygmuntowicz Date: 2005-07-29T11:59:17+09:00 Subject: Re: Ruby libraries On Jul 28, 2005, at 7:18 PM, Alexandru Popescu wrote: > #: by Ezra Zygmuntowicz's words the mind was *winged* :# > >> Andrew- >> There is an ftp library in the ruby standard library. Here is >> a little script that recursively descends through a directory >> and uploads all the files to an ftp server: >> #!/usr/local/bin/ruby >> # This script uploads a folder of images via ftp >> require 'find' >> require 'net/ftp' >> path = "/Volumes/Users/ez/logos/" # <= set this to the path of >> your folder of images >> ftp = Net::FTP.new('ftp.example.com') >> ftp.login("username", "password") >> files = ftp.chdir('logos') >> Find.find(path) do |file| >> unless test(?d, file) #<= this tests to make sure its >> a file and not a directory before continuing. >> ftp.putbinaryfile("#{file}", "#{File.basename(file)}") >> #<= this assumes binary files. >> puts "Uploaded #{file}" >> end >> end >> ftp.close >> Hope that helps >> -Ezra >> On Jul 28, 2005, at 2:41 PM, Andrew Falanga wrote: >> >>> Hi, >>> >>> New to Ruby and I'm not having much luck finding the answer to >>> this question at this time. Are there Ruby equivalents to the >>> TWAPI extension library for TCL? I need to be able to "mount" a >>> share from a script for Windows. I would also like to know if >>> there is an FTP library that can be used in Ruby. >>> >>> Currently, I'm using TCL, but I need to have threading support >>> and to my pleasant surprise, Ruby supports threading natively. >>> Plus, the language thus far, looks to be much more "fun" to work >>> with than TCL. >>> >>> Thanks in advance for any help provided. >>> >>> --------------------------------------------- >>> Andrew R. Falanga (a non-HP employee) >>> Hewlett-Packard Company >>> 11311 Chinden Blvd. >>> Boise, Idaho >>> --------------------------------------------- >>> Please note: The e-mail address is purposely >>> mangled. I do not wish my account at HP to >>> become a spam haven. >>> >>> >> -Ezra Zygmuntowicz >> Yakima Herald-Republic >> WebMaster >> 509-577-7732 >> ezra@yakima-herald.com >> > Wouldn't be correct to have the close() call in a finally block? > (so to be assured that it always run) > > :alex |.::the_mindstorm::.| > Sure, I was just throwing up a quick example. If it's code you would be using a lot definitely put it in a begin ..rescue...ensure..end block. -Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra@yakima-herald.com 509-577-7732