From: Vincent Arnoux Date: 2006-09-13T01:47:33+09:00 Subject: Re: Net::FTP questions... Le mercredi 13 septembre 2006 à 00:14 +0900, James Cribbs a écrit : Lincoln Anderson wrote: > Here's where my problem comes in. How can I tell from the list array > whether an item is a directory or a file to be copied? Is there > something I can use (such as an FTP command) to catch a clue on how to > implement this? I know this is possible, as ftpmirror is done with > PERL and Ruby can do anything PERL can do - better :) Perhaps this can be useful to browse the FTP server tree (directory names finish by '/', others are files): def recursive_listing(ftp, path) liste_ftp = Array.new list = ftp.ls(path) if list.length == 0 return [] end if list[0].split[0] == 'total' list.delete_at(0) end if list[0].split[8] == '.' list.delete_at(0) end if list[0].split[8] == '..' list.delete_at(0) end list.each { |str| if str.split[0].index('d') == 0 liste_ftp += [path + "/" + str.split[8] + "/"] liste_ftp += [recursive_listing(ftp, path + "/" + str.split[8])] else liste_ftp += [path + "/" + str.split[8]] end } return liste_ftp.flatten end ftp = Net::FTP.new('ftp_serveur') ftp.login('login', 'passwd') ftp_list = recursive_listing(ftp, 'starting_directory') ftp.close It might need some corrections depending your FTP server configuration. Cheers, Vincent