FTP problem under Linux?

K

Knute Johnson

The code below, as ugly as it is, runs perfectly on Windows but hangs at
the gettextfile under Linux. I'm using ruby-1.8.6.111-1.fc8 on Fedora 8
and ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32] under Windows
XP. I am able to use the command line ftp client to log into the site
and retrieve the file with no problems. Any ideas?

Thanks,

#!/usr/bin/ruby

require 'net/ftp'

def getMetar(id)
metar = Array.new
i = 0
ftp = Net::FTP.new('tgftp.nws.noaa.gov')
puts ftp.login
puts ftp.sendcmd('PASV')
ftp.chdir('/data/observations/metar/stations')
ftp.gettextfile("#{id.upcase}.TXT") do |line|
metar = line
i = i + 1
end
ftp.close
return metar
end

puts getMetar("KBFL")

[knute@www ~]$ ruby metar.rb
230 Login successful.
227 Entering Passive Mode (140,90,128,71,154,251)
/usr/lib/ruby/1.8/net/ftp.rb:340:in `accept': Interrupt
from /usr/lib/ruby/1.8/net/ftp.rb:340:in `transfercmd'
from /usr/lib/ruby/1.8/net/ftp.rb:421:in `retrlines'
from /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
from /usr/lib/ruby/1.8/net/ftp.rb:419:in `retrlines'
from /usr/lib/ruby/1.8/net/ftp.rb:518:in `gettextfile'
from metar.rb:13:in `getMetar'
from metar.rb:37

The error trace is generated when I press control-C after the hang.
 

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
Help - Linux? 10
tcp socket error 0
Anybody tell me about net/ftp protocol ? 2
IP FTP 0
Net::FTP hangs 7
FTP list fails on Mac OS 10.3 0
More socket problems (ftp) with Ruby and OS X 10.3 0

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top