Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Net::FTP get() problem

by rbi (Monk)
on Oct 19, 2006 at 14:02 UTC ( #579368=perlquestion: print w/ replies, xml ) Need Help??
rbi has asked for the wisdom of the Perl Monks concerning the following question:

Hello,
I've this script:
use strict; use warnings; use Net::FTP; my ($hostname,$user;$password) = ('A','B','C') # my settings here; my ($directory,$file) = ('XXX','YYY') # my settings here; my $ftp = Net::FTP->new($hostname, Debug => 1); $ftp->login($user,$password) or die "Cannot login ", $ftp->message; $ftp->cwd($directory); $ftp->binary(); $ftp->get($file) or print $ftp->message; $ftp->quit();
It works fine when the firewall on my computer is off, but when the firewall is on it hangs at RETR YYY below:
... Net::FTP=GLOB(0x970b00)>>> CWD XXX Net::FTP=GLOB(0x970b00)<<< 250 OK. Current directory is /XXX Net::FTP=GLOB(0x970b00)>>> TYPE I Net::FTP=GLOB(0x970b00)<<< 200 TYPE is now 8-bit binary Net::FTP=GLOB(0x970b00)>>> PORT 10,0,0,5,111,10 Net::FTP=GLOB(0x970b00)<<< 200 PORT command successful Net::FTP=GLOB(0x970b00)>>> RETR YYY
Instead, when I use the ftp command from prompt with the same commands, I can successfully retrieve the file both with and without the firewall.
Any hint is appreciated a lot. Thanks.

Comment on Net::FTP get() problem
Select or Download Code
Re: Net::FTP get() problem
by Melly (Hermit) on Oct 19, 2006 at 14:07 UTC

    Have you tried setting Passive to 1?

    Try (untested):

    my $ftp = Net::FTP->new($hostname, Debug => 1, Passive => 1);
    Tom Melly, tom@tomandlu.co.uk
      Thanks a lot, it works!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://579368]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2014-07-23 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (138 votes), past polls