Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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:

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
Replies are listed 'Best First'.
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,
      Thanks a lot, it works!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2015-11-26 19:49 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (706 votes), past polls