DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Ruby (http://www.daniweb.com/forums/forum73.html)
-   -   FTP - Download multiple files using ruby (http://www.daniweb.com/forums/thread186694.html)

shekarls Apr 15th, 2009 4:15 am
FTP - Download multiple files using ruby
 
I have written ftp code which will download a single file from the
Server using the below code:

require 'rubygems'
require 'net/ftp'
require 'fileutils'

URL = 'IP address'
username = 'test'
passwd = "test"
filename = "file1"
directory = '/home/test/'
localfile = 'C:\\Documents and Settings\\User1\\Desktop\\file1'
ftp=Net::FTP.new
ftp.connect(URL,21)
ftp.login(username,passwd)
ftp.chdir(directory)
ftp.getbinaryfile(filename,localfile)
ftp.close

But what i am really looking for is:
1) Download multiple files from a given directory.
2) Download files by giving wild characters (eg: *.xls or *.txt)

Please let me know if there is a better way or easier way to achieve
these tasks.

cheers


All times are GMT -4. The time now is 1:09 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC