Anybody tell me about net/ftp protocol ?

A

Arul hari

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

ftp = Net::FTP::new("ftp.ruby-lang.org")
ftp.login("anonymous", "(e-mail address removed)")
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
 
A

Alex Gutteridge

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

ftp = Net::FTP::new("ftp.ruby-lang.org")
ftp.login("anonymous", "(e-mail address removed)")
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

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")
ftp.login("anonymous", "(e-mail address removed)")
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 Gutteridge

Bioinformatics Center
Kyoto University
 
G

Gordon Beaton

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

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Error using net::ftp 1
tcp socket error 0
Net::FTP hangs 7
Net::FTP error on WinXP with firewall enabled 1
FTP problem under Linux? 0
Does Ruby's FTP lib have a ghostly bug? 16
IP FTP 0
Problem with Net::FTP#mtime 1

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top