I have setup an ftp script to fetch all files from a directory on my ftp
server...
my bit of code looks like this,
files = ftp.chdir('folder')
files_list = ftp.dir
log.info "found files, #{files_list}"
log.info "Making attempt to fetch all files"
files_list.each do |file|
ftp.get(file)
end
but ftp.dir return really silly filename, so when ftp tries to fetch
these files, it moans it can't find them.
I have tried all the other ftp list methods, but they all do the same
thing.
What can I do?
Andrew
···
--
Posted via http://www.ruby-forum.com/.
Andrew Doades wrote:
but ftp.dir return really silly filename, so when ftp tries to fetch
Define "really silly filename". Show a dir of the directory, then show what your Ruby script is returning.
···
--
Michael Morin
Guide to Ruby
Become an About.com Guide: beaguide.about.com
About.com is part of the New York Times Company
Michael Morin wrote:
Andrew Doades wrote:
but ftp.dir return really silly filename, so when ftp tries to fetch
Define "really silly filename". Show a dir of the directory, then show
what your Ruby script is returning.
This is what the log returns
found files, 08-30-08 02:10AM 196700640 file_20080830.7z
Making attempt to fetch all files
Error:550 08-30-08 02:10AM 196700640 file_20080830.7z: The
system cannot find the file specified.
···
--
Posted via http://www.ruby-forum.com/\.
Andrew Doades wrote:
Michael Morin wrote:
Andrew Doades wrote:
but ftp.dir return really silly filename, so when ftp tries to fetch
Define "really silly filename". Show a dir of the directory, then show
what your Ruby script is returning.
This is what the log returns
found files, 08-30-08 02:10AM 196700640 file_20080830.7z
Making attempt to fetch all files
Error:550 08-30-08 02:10AM 196700640 file_20080830.7z: The system cannot find the file specified.
Those aren't "really silly filenames," those are the lines returned by the DIR command. Extract the filenames using split(/\s+/, 4). I'm not sure, but I don't think FTP defines any specific format for DIR output, so this might not work on all servers.
···
--
Michael Morin
Guide to Ruby
Become an About.com Guide: beaguide.about.com
About.com is part of the New York Times Company
Michael Morin wrote:
Andrew Doades wrote:
Error:550 08-30-08 02:10AM 196700640 file_20080830.7z: The
system cannot find the file specified.
Those aren't "really silly filenames," those are the lines returned by
the DIR command. Extract the filenames using split(/\s+/, 4). I'm not
sure, but I don't think FTP defines any specific format for DIR output,
so this might not work on all servers.
OK, I have added that split line in here,
files_list.each.split(/\s+/, 4) do |file|
now I get the error,
Error:no block given
Must be doing something write, got a lot further
···
--
Posted via http://www.ruby-forum.com/\.
Andrew Doades wrote:
Michael Morin wrote:
Andrew Doades wrote:
Error:550 08-30-08 02:10AM 196700640 file_20080830.7z: The
system cannot find the file specified.
Those aren't "really silly filenames," those are the lines returned by
the DIR command. Extract the filenames using split(/\s+/, 4). I'm not
sure, but I don't think FTP defines any specific format for DIR output,
so this might not work on all servers.
OK, I have added that split line in here,
files_list.each.split(/\s+/, 4) do |file|
now I get the error,
Error:no block given
Must be doing something write, got a lot further
Fixed it!
I replaced files_list = ftp.dir with files_list = ftp.nlst
···
--
Posted via http://www.ruby-forum.com/\.