Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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("")) { 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("")) 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/ 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?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2016-05-28 04:38 GMT
Find Nodes?
    Voting Booth?