<?xml version="1.0" encoding="windows-1252"?>
<node id="816061" title="Re: Perl Net::FTP put() gives little help on errors" created="2010-01-07 04:45:59" updated="2010-01-07 04:45:59">
<type id="11">
note</type>
<author id="62157">
tokpela</author>
<data>
<field name="doctext">
&lt;p&gt;
You are not checking for errors.
&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;This code is untested&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;
use strict;
use warnings;

use Net::FTP;

my $ftp = Net::FTP-&gt;new($server, Timeout=&gt;1800, Passive=&gt;1, Debug=&gt;3) or 
                 die "[Error] UNABLE TO CREATE FTP OBJECT: [$@]";

if ($ftp-&gt;login($user, $pswd)) {

  $ftp-&gt;cwd("files");
  $ftp-&gt;binary();
  if (! $ftp-&gt;put("build.zip")) {

     my $ftp_message           = $ftp-&gt;message;
     chomp($ftp_message);
     print "[Error] UNABLE TO PUT FILE - [$ftp_message]\n";

   }

} else {

   my $ftp_message           = $ftp-&gt;message;
   chomp($ftp_message);
   die "[Error] UNABLE TO LOGIN TO FTP [$server] USING LOGIN ACCOUNT: [$user]-[$ftp_message]\n";

}
&lt;/code&gt;
&lt;/p&gt;</field>
<field name="root_node">
816043</field>
<field name="parent_node">
816043</field>
</data>
</node>
