Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Net::SFTP::Foreign Connection STDERR
by salva (Canon) on Mar 16, 2017 at 07:45 UTC | |
by Anonymous Monk on Mar 17, 2017 at 13:38 UTC |