Hello all, I am writing a program that has a subroutine to do an FTP put to a server. My problem is I am looking for a way to determine if the FTP was sucessful or not, if not give as much info on the error as possible and pass that info back to my program regardless of success or failure.
sub PutFTP { ################################################################## +######################## # # This subroutine performs an FTP Put using the Net::FTP module # ################################################################## +######################## my $ftp_server = shift(@_); my $sub_pass = shift(@_); my $sub_uid = 'weblog'; my $sub_path = shift(@_); my $sub_log = shift(@_); print "Beginning FTP Put to $ftp_server. Putting log $sub_log to p +ath $sub_path\n\n"; print "FTP Debug output:\n\n"; my $ftp = Net::FTP->new("$ftp_server", Debug => 1, Timeout => 1300 +) or ErrorOut("Cannot connect to $ftp_server: $@"); $ftp->login($sub_uid,$sub_pass) or ErrorOut("Cannot login ", $ftp->message); $ftp->cwd($sub_path) or ErrorOut("Cannot change working directory ", $ftp->message); $ftp->put($sub_log) or ErrorOut("put failed ", $ftp->message); $ftp->quit; print "\nEnd FTP debug output\n\n"; if ($ftp->put($sub_log)) { print "FTP Put successful from server $ftp_server\n"; }else{ print "FTP Put Failed\n"; } } # End sub NetFTP
Every time it runs it says the put failed. Thanks in advance, Nick

In reply to Error Checking with Net::FTP by nickfaber

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.