Net::FTP

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

Andrew D. 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 M. wrote:

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

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

Michael M. wrote:

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

Andrew D. wrote:

Michael M. wrote:

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