Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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
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 rifling through the Monastery: (8)
As of 2014-08-30 20:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls