Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Question on Net::Ftp..

by kprasanna_79 (Hermit)
on Jan 26, 2009 at 19:33 UTC ( [id://739011]=perlquestion: print w/replies, xml ) Need Help??

kprasanna_79 has asked for the wisdom of the Perl Monks concerning the following question:

Revered Monks,

I am trying to use Net::Ftp module to connect to another UNIX machine. But i dont see any thing actually happening when i use this module and also i do get the below error...

require 5.6.1; use Net::FTP; my $ftp = Net::FTP->new('ostrich',Debug=>1,Passive=>1) or die "not con +nected $!"; print "connected successfully\n";
The error is not connected Invalid argument at - line 3.
Please throw some light on this
Update:-
The normal ftp (/usr/bin/ftp)in UNIX session works fine.

Update1:-

Recently i notice that it doesnt recognise the hostname. Is it any where i need to mention this hostname to be identified by the Net::Ftp modue?????Like Netrc file or somewhere???

-Prasanna.K

Replies are listed 'Best First'.
Re: Question on Net::Ftp..
by runrig (Abbot) on Jan 26, 2009 at 21:11 UTC
    Net::FTP->new(...) error messages are in $@, not $!. After that, messages can be retrieved with the message() method.
Re: Question on Net::Ftp..
by Illuminatus (Curate) on Jan 26, 2009 at 19:49 UTC
    1. Have you tried Host => 'ostrich'? I'm not sure you can pass an implicit hostname with other named parameters
    2. can you 'ftp ostrich' from the command line?
Re: Question on Net::Ftp..
by hbm (Hermit) on Jan 26, 2009 at 20:08 UTC

    Can you connect with /usr/bin/ftp (or whichever)?

    You might want to extend the timeout and retry a few times, like this:

    use Net::FTP; my $ftphost = 'ftp.ostrich.com'; my $timeout = 600; # seconds, default is 120 my $retries = 5; for (1 .. $retries) { last if $ftp = Net::FTP->new("$ftphost", BlockSize => 20480, T +imeout => $timeout); } die("Couldn't connect to $ftphost in $retries attempts: $@") unle +ss($ftp); ...

    Update: Upon closer inspection, I think you just need to wrap ostrich with double-quotes in Net::FTP->new("ostrich",...). I get an error, albeit somewhat different, if I change my doubles to singles as you have.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found