Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: ftp return value

by atopolc (Pilgrim)
on May 16, 2002 at 12:51 UTC ( #166991=note: print w/ replies, xml ) Need Help??


in reply to ftp return value

To do proper error checking after each put. I think you should check the return code explicitly and then return the error message from ftp. Here is how I would do it.

$ftp = Net::FTP->new("mysys",Port => 9021,Timeout => 20, Debug => 0); $ftp->login("anonymous",'me@myself.com'); $ftp->put("$dir/$file1"); my $rtncode=$ftp->code; if ($rtncode != 226 && $rtncode != 250) { my $msg=$ftp->message; print "FTP Failed: $msg\n"; $ftp->quit; } #do remainder of your puts here.

The '226' and the '250' are both return codes used in FTP. You can read more about them in the RFC for ftp.
update: to fix link


Comment on Re: ftp return value
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2014-09-22 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (208 votes), past polls