I would suggest adding the following (at the top of your script) for debugging:

use strict; use warnings; use Carp; # other use statements here... $SIG{__DIE__} = sub { Carp::confess @_ }; # remainder of your code here...

I would then run the code. The Carp::confess will (effectively) give you a full stack trace of calls when the die() occurred. You can then see where your script was when the error occurred.

My hunch is that when your Net::SFTP connection failed and the program exited (error 1), error 2 was generated because the database handle was destroyed (forcing the rollback) with no disconnect.

You may want to consider opening the database connection after you have the SSH/SFTP connection completed, using a signal handler to clean up the database handle if an error occurs, or change the way the database connection is created (although I doubt that one is what you want).

Hope that helps.


In reply to Re: ftp to sftp migration in perl by atcroft
in thread ftp to sftp migration in perl by maddyfloss

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.