# Odd Net::FTP behavior

**URL:** <https://rubytalk.org/t/odd-net-ftp-behavior/29847>\
**Category:** ruby-talk\
**Created:** [10 August 2006 20:40 UTC](https://rubytalk.org/t/odd-net-ftp-behavior/29847 "2006-08-10T20:40:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![HAL\_90001](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/hal_90001/32/2046_2.png) [@HAL\_90001](https://rubytalk.org/u/HAL_90001)\
**Post date:** [10 August 2006 20:40 UTC](https://rubytalk.org/t/odd-net-ftp-behavior/29847/1 "2006-08-10T20:40:15Z")

</div>

Here's my (simple) code. This has worked fine in the past;  
now even this simple example fails for me.

It gets as far as creating an empty file, then it hangs and  
times out.

This is Ruby 1.8.4 on FC4, talking to another Linux box  
(RH Enterprise I think).

Any ideas?

Hal

domain, user, password = "[mydomain.com](http://mydomain.com)", "myuser", "mypass"  
args = [domain]  
args \<\< user \<\< password if user != nil  
puts "Connecting..."  
@ftp = Net::FTP.new(\*args)  
@rempath = "/var/www/html/whatever/"  
puts "Change dir..."  
@ftp.chdir(@rempath)

puts "Upload file..."  
@ftp.puttextfile("foobar","foobar-rem") # Hangs here!  
puts "Closing..."  
@ftp.close  
puts "Finished."

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard6](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ara.T.Howard6](https://rubytalk.org/u/Ara.T.Howard6)\
**Post date:** [10 August 2006 20:44 UTC](https://rubytalk.org/t/odd-net-ftp-behavior/29847/2 "2006-08-10T20:44:17Z")

</div>

@ftp.passive = true ??

-a

> **···**
>
> On Fri, 11 Aug 2006 rubyhacker@gmail.com wrote:
> 
> > Here's my (simple) code. This has worked fine in the past;  
> > now even this simple example fails for me.
> > 
> > It gets as far as creating an empty file, then it hangs and  
> > times out.
> > 
> > This is Ruby 1.8.4 on FC4, talking to another Linux box  
> > (RH Enterprise I think).
> > 
> > Any ideas?
> > 
> > Hal
> > 
> > domain, user, password = "mydomain.com", "myuser", "mypass"  
> > args = [domain]  
> > args \<\< user \<\< password if user != nil  
> > puts "Connecting..."  
> > @ftp = Net::FTP.new(\*args)  
> > @rempath = "/var/www/html/whatever/"  
> > puts "Change dir..."  
> > @ftp.chdir(@rempath)
> > 
> > puts "Upload file..."  
> > @ftp.puttextfile("foobar","foobar-rem") # Hangs here!  
> > puts "Closing..."  
> > @ftp.close  
> > puts "Finished."
> 
> --  
> to foster inner awareness, introspection, and reasoning is more efficient than  
> meditation and prayer.  
> - h.h. the 14th dali lama

---

<div class="post-metadata">

**Author:** ![HAL\_90001](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/hal_90001/32/2046_2.png) [@HAL\_90001](https://rubytalk.org/u/HAL_90001)\
**Post date:** [10 August 2006 20:50 UTC](https://rubytalk.org/t/odd-net-ftp-behavior/29847/3 "2006-08-10T20:50:13Z")

</div>

Quite right, thank you.

Never needed that before. Wonder why I do now.  
Not even sure what passive means.

Eventually I'll move this app on to sftp anyway.

Thanks,  
Hal

> **···**
>
> ara.t.how...@noaa.gov wrote:
> 
> > On Fri, 11 Aug 2006 rubyhacker@gmail.com wrote:  
> > \>  
> > \> Any ideas?
> > 
> > @ftp.passive = true ??

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard6](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ara.T.Howard6](https://rubytalk.org/u/Ara.T.Howard6)\
**Post date:** [10 August 2006 21:00 UTC](https://rubytalk.org/t/odd-net-ftp-behavior/29847/4 "2006-08-10T21:00:55Z")

</div>

it's kinda confusing - i stumble on it from time to time - probably better to  
google it than listen to me. in any case the change would have been due to a  
change on the server - not your stuff. probably 😉

-a

> **···**
>
> On Fri, 11 Aug 2006 rubyhacker@gmail.com wrote:
> 
> > ara.t.how...@noaa.gov wrote:
> > 
> > > On Fri, 11 Aug 2006 rubyhacker@gmail.com wrote:
> > > 
> > > > Any ideas?
> > > 
> > > @ftp.passive = true ??
> > 
> > Quite right, thank you.
> > 
> > Never needed that before. Wonder why I do now.  
> > Not even sure what passive means.
> > 
> > Eventually I'll move this app on to sftp anyway.
> > 
> > Thanks,  
> > Hal
> 
> --  
> to foster inner awareness, introspection, and reasoning is more efficient than  
> meditation and prayer.  
> - h.h. the 14th dali lama

---

<div class="post-metadata">

**Author:** ![Francis\_Cianfrocca](https://avatars.discourse-cdn.com/v4/letter/f/7bcc69/32.png) [@Francis\_Cianfrocca](https://rubytalk.org/u/Francis_Cianfrocca)\
**Post date:** [10 August 2006 21:18 UTC](https://rubytalk.org/t/odd-net-ftp-behavior/29847/5 "2006-08-10T21:18:43Z")

</div>

Someone may have tightened up the firewalls that previously were allowing  
your server to make TCP connections on ephemeral ports to your client  
machine. Or you're doing this from a different client than you're used to  
and the topology is different.

> **···**
>
> On 8/10/06, rubyhacker@gmail.com \<rubyhacker@gmail.com\> wrote:
> 
> > ara.t.how...@noaa.gov wrote:  
> > \> On Fri, 11 Aug 2006 rubyhacker@gmail.com wrote:  
> > \> \>  
> > \> \> Any ideas?  
> > \>  
> > \> @ftp.passive = true ??  
> > \>
> > 
> > Quite right, thank you.
> > 
> > Never needed that before. Wonder why I do now.  
> > Not even sure what passive means.
> > 
> > Eventually I'll move this app on to sftp anyway.
> > 
> > Thanks,  
> > Hal
