# FTP problem under Linux?

**URL:** <https://www.ruby-forum.com/t/ftp-problem-under-linux/129578>\
**Category:** Ruby\
**Created:** [February 19, 2008, 8:22pm UTC](https://www.ruby-forum.com/t/ftp-problem-under-linux/129578 "2008-02-19T20:22:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Knute\_Johnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/958977/32.png) [@Knute\_Johnson](https://www.ruby-forum.com/u/Knute_Johnson)\
**Post date:** [February 19, 2008, 8:22pm UTC](https://www.ruby-forum.com/t/ftp-problem-under-linux/129578/1 "2008-02-19T20:22:39Z")

</div>

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](http://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[i] = 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.

–

Knute Johnson  
email s/nospam/knute/
