Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Perl Net::FTP put() gives little help on errors

by tokpela (Chaplain)
on Jan 07, 2010 at 09:45 UTC ( #816061=note: print w/ replies, xml ) Need Help??


in reply to Perl Net::FTP put() gives little help on errors

You are not checking for errors.

This code is untested

use strict; use warnings; use Net::FTP; my $ftp = Net::FTP->new($server, Timeout=>1800, Passive=>1, Debug=>3) +or die "[Error] UNABLE TO CREATE FTP OBJECT: [$@]"; if ($ftp->login($user, $pswd)) { $ftp->cwd("files"); $ftp->binary(); if (! $ftp->put("build.zip")) { my $ftp_message = $ftp->message; chomp($ftp_message); print "[Error] UNABLE TO PUT FILE - [$ftp_message]\n"; } } else { my $ftp_message = $ftp->message; chomp($ftp_message); die "[Error] UNABLE TO LOGIN TO FTP [$server] USING LOGIN ACCOUNT: +[$user]-[$ftp_message]\n"; }


Comment on Re: Perl Net::FTP put() gives little help on errors
Download Code
Replies are listed 'Best First'.
Re^2: Perl Net::FTP put() gives little help on errors
by amitsk (Initiate) on Jan 07, 2010 at 10:05 UTC

    Even when checking for errors like having if (! $ftp->put("build.zip")) and getting $ftp_message, the $ftp_message is still empty!

    note, on the cmd window, I am seeing this
    Net::FTP: Unexpected EOF on command channel at C:/Perl/lib/Net/FTP/dataconn.pm line 73
    so question if why is $ftp->message empty?

      A guess here, I found this comment in my version of C:/Perl/lib/Net/FTP/dataconn ($VERSION=0.11) in the abort function.
      # for some reason if we continously open RETR connections and not # read a single byte, then abort them after a while the server will # close our connection, this prevents the unexpected EOF on the # command channel -- GMB
      In this case the code aborts - it does not appear to update the error message.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (12)
As of 2015-07-08 07:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (96 votes), past polls