Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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.

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2017-11-20 17:02 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (289 votes). Check out past polls.