# Re: newbie ftp problem

**URL:** <https://www.ruby-forum.com/t/re-newbie-ftp-problem/72773>\
**Category:** Ruby\
**Created:** [October 18, 2006, 8:20pm UTC](https://www.ruby-forum.com/t/re-newbie-ftp-problem/72773 "2006-10-18T20:20:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 18, 2006, 8:20pm UTC](https://www.ruby-forum.com/t/re-newbie-ftp-problem/72773/1 "2006-10-18T20:20:23Z")

</div>

From: removed\_email\_address@domain.invalid [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

> files = ftp.nlst(‘data’)
> 
> Net::FTPPermError: 500 Invalid PORT command.

You changed directories into ‘data’, and are then trying to list a  
‘data’ dir?

FWIW, all the above worked fine with me using Ruby 1.8.5 on Windows,  
going to a known-working and accessible FTP server. Smells like either a  
firewall/port-blocking issue, or a double-NAT issue. To be sure: can you  
FTP from the command line/shell just fine?

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 18, 2006, 8:48pm UTC](https://www.ruby-forum.com/t/re-newbie-ftp-problem/72773/2 "2006-10-18T20:48:51Z")

</div>

On Thu, 19 Oct 2006, Gavin K. wrote:

> From: removed\_email\_address@domain.invalid [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]
> 
> > ftp = Net::FTP::new(‘[my.url.com](http://my.url.com)’)  
> > ftp.login(‘login\_id’,‘login\_pass’,nil)  
> > ftp.chdir(‘data’)
> > 
> > all goes fine but at this point I have tried all of the following and  
> > get the same errors

try

ftp.passive = true

> > files = ftp.list(‘data’)  
> > files = ftp.dir(‘data’)  
> > files = ftp.dir(dir = nil)  
> > files = ftp.nlst(‘data’)
> > 
> > Net::FTPPermError: 500 Invalid PORT command.

-a

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 18, 2006, 8:50pm UTC](https://www.ruby-forum.com/t/re-newbie-ftp-problem/72773/3 "2006-10-18T20:50:51Z")

</div>

Gavin K. wrote:

> > files = ftp.dir(dir = nil)  
> > FTP from the command line/shell just fine?  
> > I see what your saying about the ‘data’ directory and I re-did it  
> > without changing to the ‘data’ directory and get the same error. See  
> > sample code below;

irb(main):006:0\> ftp.login(‘bruskeftp’,‘35sumler75’,nil)  
=\> “230 User bruskeftp logged in.\n”  
irb(main):007:0\> files = ftp.dir(‘data’)  
Net::FTPPermError: 500 Invalid PORT Command.

```
from c:/ruby/freeride/freeruby-win/lib/ruby/1.8/net/ftp.rb:243:in

```

`getresp' from c:/ruby/freeride/freeruby-win/lib/ruby/1.8/net/ftp.rb:251:in`voidresp’  
from c:/ruby/freeride/freeruby-win/lib/ruby/1.8/net/ftp.rb:274:in  
`voidcmd' from c:/ruby/freeride/freeruby-win/lib/ruby/1.8/monitor.rb:229:in`synchronize’  
from c:/ruby/freeride/freeruby-win/lib/ruby/1.8/net/ftp.rb:272:in  
`voidcmd' from c:/ruby/freeride/freeruby-win/lib/ruby/1.8/net/ftp.rb:290:in`sendport’  
from c:/ruby/freeride/freeruby-win/lib/ruby/1.8/net/ftp.rb:298:in  
`makeport' from c:/ruby/freeride/freeruby-win/lib/ruby/1.8/net/ftp.rb:329:in`transfercmd’  
from c:/ruby/freeride/freeruby-win/lib/ruby/1.8/net/ftp.rb:421:in  
`retrlines' from c:/ruby/freeride/freeruby-win/lib/ruby/1.8/monitor.rb:229:in`synchronize’  
from c:/ruby/freeride/freeruby-win/lib/ruby/1.8/net/ftp.rb:419:in  
`retrlines' from c:/ruby/freeride/freeruby-win/lib/ruby/1.8/net/ftp.rb:628:in`dir’  
from (irb):7  
from :0

I hate to bring up the “P” word but I did the same thing using python  
and had no problem. Sample code below;

> > > ftp.login(‘bruskeftp’,‘35sumler75’)  
> > > ‘230 User bruskeftp logged in.’
> 
> > > ftp.dir(‘data’)  
> > > 10-17-06 01:08PM 19377920 cust.TPS  
> > > 10-17-06 06:29AM 30131456 detail.tps  
> > > 10-12-06 12:32AM 771584 Item.tps  
> > > 10-18-06 02:18AM 3072 mgr.tps  
> > > 10-17-06 06:29AM 617728 open.tps  
> > > 10-17-06 08:40AM 237056 OpnInv.TPS  
> > > 10-18-06 01:34AM 95488 OrdHdr.tps  
> > > 10-17-06 08:24AM 135424 OrdLin.tps  
> > > 10-15-06 12:56AM 4864 PCOrdHdr.TPS  
> > > 10-15-06 12:56AM 4352 PCOrdLin.TPS  
> > > 10-12-06 12:30AM 303616 Price.tps  
> > > 10-18-06 02:18AM 25088 slsmn.tps

Unfortunetly, I am really new to Ruby, and really wanted to start using  
it for some production stuff.

I want to thank you for your time and help if you happen to think of  
anything else I will give it a shot.

Len S.

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 18, 2006, 9:08pm UTC](https://www.ruby-forum.com/t/re-newbie-ftp-problem/72773/4 "2006-10-18T21:08:56Z")

</div>

Looks like a passive ftp mode problem versus standard ftp using port 20,  
and 21. See if at the api you can turn passive mode on.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 18, 2006, 9:12pm UTC](https://www.ruby-forum.com/t/re-newbie-ftp-problem/72773/5 "2006-10-18T21:12:57Z")

</div>

removed\_email\_address@domain.invalid wrote:

> try
> 
> ## -a
> 
> my religion is very simple. my religion is kindness. – the dalai lama

Tried the passive - still get the same error

Thanks  
Len S.

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 18, 2006, 9:23pm UTC](https://www.ruby-forum.com/t/re-newbie-ftp-problem/72773/6 "2006-10-18T21:23:00Z")

</div>

John P. wrote:

> > > > ftp.chdir(‘data’)  
> > > > You changed directories into ‘data’, and are then trying to list a
> > 
> > `voidcmd’  
> > from c:/ruby/freeride/freeruby-win/lib/ruby/1.8/net/ftp.rb:421:in
> > 
> > 10-17-06 06:29AM 617728 open.tps
> > 
> > I want to thank you for your time and help if you happen to think of  
> > anything else I will give it a shot.
> > 
> > Len S.

I’m sorry I retried the setting of passive and that DID fix the  
problem.

I want to thank you all for your time and your help and I hope someday  
to be able to help others out on this ng.

Thanks  
Len S.
