Hi.

I realize this is a very old chain but I figured I would take a chance and post a follow-on question. Identical, I think to the problem mentioned above.

I have a parent process that looks for delivery jobs to be handled and dispatches child processes to do those deliveries. The SFTP child process uses Net::SFTP::Foreign and uses STDERR redirect suggested above. The relevant piece of code looks like:

my $host = $delivery->{HOST}; my $ssherr = File::Temp->new or die "File::Temp->new failed"; my %sftp_params = ( 'user' => $delivery->{LOGIN}, 'password' => $delivery->{PASSWORD}, 'more' => ['-v'], 'stderr_fh' => $ssherr, ); if($delivery->{PORT}) { $sftp_params{'port'} = $delivery->{PORT}; } &logPrint("connecting to host '$host' via SFTP"); $sftp = Net::SFTP::Foreign->new($host, %sftp_params); if ($sftp->error) { &logFatal("unable to connect to host '$host': " . $sftp->error +); seek($ssherr, 0, 0); while (<$ssherr>) { &logFatal("captured stderr: $_\n"); } return undef; }

My problem is that if there is a problem (remote host is incorrect, remote host has blocked access) the child process still doesn't seem to be aware of that. Output looks like:

2017/03/15 15:36:59 UnsiloManager doing deliver 2017/03/15 15:36:59 Deliver::SFTP getting delivery specs... 2017/03/15 15:36:59 Deliver::SFTP Connecting to: 'ftp.unsilo.co +m' via SFTP

Meanwhile the parent/dispatcher process is never aware of the fact that the child/SFTP process had a problem and sits around and waits:

2017/03/15 15:36:59 main trying to spawn child for job +nature_v9_n222_xml_unsilo_20170315150444.deliver 2017/03/15 15:36:59 main spawning new child process '18 +385' 2017/03/15 15:36:59 main 1 jobs currently running 2017/03/15 15:37:59 main DEBUG child process '18385' still ru +nning 2017/03/15 15:37:59 main 1 jobs currently running 2017/03/15 15:38:59 main DEBUG child process '18385' still ru +nning 2017/03/15 15:38:59 main 1 jobs currently running

So clearly there's still something wrong with the way I've coded the SFTP child process. Is there anything that someone might be able to suggest?


In reply to Re^2: Net::SFTP::Foreign Connection STDERR by Anonymous Monk

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.