# Net::FTP

**URL:** <https://www.ruby-forum.com/t/net-ftp/147295>\
**Category:** Ruby\
**Created:** [August 30, 2008, 4:03pm UTC](https://www.ruby-forum.com/t/net-ftp/147295 "2008-08-30T16:03:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewdon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@andrewdon](https://www.ruby-forum.com/u/andrewdon)\
**Post date:** [August 30, 2008, 4:03pm UTC](https://www.ruby-forum.com/t/net-ftp/147295/1 "2008-08-30T16:03:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andrewdon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@andrewdon](https://www.ruby-forum.com/u/andrewdon)\
**Post date:** [August 30, 2008, 4:20pm UTC](https://www.ruby-forum.com/t/net-ftp/147295/2 "2008-08-30T16:20:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andrewdon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@andrewdon](https://www.ruby-forum.com/u/andrewdon)\
**Post date:** [August 30, 2008, 4:24pm UTC](https://www.ruby-forum.com/t/net-ftp/147295/3 "2008-08-30T16:24:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andrewdon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@andrewdon](https://www.ruby-forum.com/u/andrewdon)\
**Post date:** [August 30, 2008, 4:39pm UTC](https://www.ruby-forum.com/t/net-ftp/147295/4 "2008-08-30T16:39:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andrewdon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@andrewdon](https://www.ruby-forum.com/u/andrewdon)\
**Post date:** [August 30, 2008, 5:19pm UTC](https://www.ruby-forum.com/t/net-ftp/147295/5 "2008-08-30T17:19:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andrewdon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@andrewdon](https://www.ruby-forum.com/u/andrewdon)\
**Post date:** [August 30, 2008, 11:18pm UTC](https://www.ruby-forum.com/t/net-ftp/147295/6 "2008-08-30T23:18:25Z")

</div>

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
