# Anybody tell me about net/ftp protocol?

**URL:** <https://www.ruby-forum.com/t/anybody-tell-me-about-net-ftp-protocol/117676>\
**Category:** Ruby\
**Created:** [October 19, 2007, 8:30am UTC](https://www.ruby-forum.com/t/anybody-tell-me-about-net-ftp-protocol/117676 "2007-10-19T08:30:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vellingiri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5fc32e/32.png) [@vellingiri](https://www.ruby-forum.com/u/vellingiri)\
**Post date:** [October 19, 2007, 8:30am UTC](https://www.ruby-forum.com/t/anybody-tell-me-about-net-ftp-protocol/117676/1 "2007-10-19T08:30:26Z")

</div>

Dear Friends,  
I am having the source code like this.  
require ‘net/ftp’

ftp = Net::FTP::new(“[ftp.ruby-lang.org](http://ftp.ruby-lang.org)”)  
ftp.login(“anonymous”, “removed\_email\_address@domain.invalid”)  
ftp.chdir(“/pub/ruby”)  
tgz = ftp.list(“ruby-\*.tar.gz”).sort.last  
print "the latest version is ", tgz, “\n”  
ftp.getbinaryfile(tgz, tgz)  
ftp.close

while running this code It is not working properly.  
as long as it is simply running,But I am not getting any result.  
After pressing ctrl+c I got the error like this.  
Please anybody clarify my doubts.  
The error is:

/usr/lib/ruby/1.8/net/ftp.rb:211:in `readline': Interrupt from /usr/lib/ruby/1.8/net/ftp.rb:211:in `getline’  
from /usr/lib/ruby/1.8/net/ftp.rb:221:in `getmultiline' from /usr/lib/ruby/1.8/net/ftp.rb:235:in `getresp’  
from /usr/lib/ruby/1.8/net/ftp.rb:251:in `voidresp' from /usr/lib/ruby/1.8/net/ftp.rb:176:in `connect’  
from /usr/lib/ruby/1.8/monitor.rb:238:in `synchronize' from /usr/lib/ruby/1.8/net/ftp.rb:174:in `connect’  
from /usr/lib/ruby/1.8/net/ftp.rb:136:in `initialize' from net.rb:3:in `new’  
from net.rb:3

---

<div class="post-metadata">

**Author:** ![vellingiri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5fc32e/32.png) [@vellingiri](https://www.ruby-forum.com/u/vellingiri)\
**Post date:** [October 19, 2007, 9:30am UTC](https://www.ruby-forum.com/t/anybody-tell-me-about-net-ftp-protocol/117676/2 "2007-10-19T09:30:45Z")

</div>

On 19 Oct 2007, at 15:30, Arul hari wrote:

> ## ftp.close from /usr/lib/ruby/1.8/net/ftp.rb:235:in `getresp' from /usr/lib/ruby/1.8/net/ftp.rb:251:in `voidresp’ from /usr/lib/ruby/1.8/net/ftp.rb:176:in `connect' from /usr/lib/ruby/1.8/monitor.rb:238:in `synchronize’ from /usr/lib/ruby/1.8/net/ftp.rb:174:in `connect' from /usr/lib/ruby/1.8/net/ftp.rb:136:in `initialize’ from net.rb:3:in `new’ from net.rb:3
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Your code works for me, which suggests there was either a problem  
with the ftp server when you tried it or there’s something wrong with  
your connection/firewall. Unrelated to your problem above, you’ll  
have to make a small change in your dir listing code to get it to  
properly work:

require ‘net/ftp’

ftp = Net::FTP::new(“[ftp.ruby-lang.org](http://ftp.ruby-lang.org)”)  
ftp.login(“anonymous”, “removed\_email\_address@domain.invalid”)  
ftp.chdir(“/pub/ruby”)  
tgz = ftp.list(“ruby-\*.tar.gz”).map{|l| l.split[8]}.sort.last  
print "the latest version is ", tgz, “\n”  
ftp.getbinaryfile(tgz, tgz)  
ftp.close

Alex G.

Bioinformatics Center  
Kyoto University

---

<div class="post-metadata">

**Author:** ![vellingiri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5fc32e/32.png) [@vellingiri](https://www.ruby-forum.com/u/vellingiri)\
**Post date:** [October 19, 2007, 9:40am UTC](https://www.ruby-forum.com/t/anybody-tell-me-about-net-ftp-protocol/117676/3 "2007-10-19T09:40:42Z")

</div>

On Fri, 19 Oct 2007 16:29:59 +0900, Alex G. wrote:

> Your code works for me, which suggests there was either a problem  
> with the ftp server when you tried it or there’s something wrong  
> with your connection/firewall.

Probably the OP needs to put the connection in passive mode.

/gordon
