Wise Monks, I have been trying to use Net::OpenSSH to create shared pipes across a SSH session. These are used to pass simple ASCII messages back and forth across servers. In total, there are 8 of these SSH sessions created using Net::OpenSSH as such:
And the STDOUT pipe is setup to be read asynchronously:my %con_opts; $con_opts{host} = $host; $con_opts{timeout} = 120; $con_opts{async} = 1; $ssh{'SSH'} = Net::OpenSSH->new(%con_opts); # For Net::OpenSSH need to specify whether to create # pipes or not, default is no pipes. my %opts; $opts{stdin_pipe} = 1; $opts{stdout_pipe} = 1; $opts{stderr_to_stdout} = 1; # Kick off the script on the remote machine ($ssh{'STDIN'}, $ssh{'STDOUT'}, undef, $ssh{'PID'}) = $ssh{'SSH'}->open_ex(\%opts, $script) or die "Error ".$ssh{$host}->error;
my $Q = new Thread::Queue; # Kick this off asynchronously to put things into the # queue to read whenever we get to it async{ while(<$pipe>) { $Q->enqueue( $_ ); } $Q->enqueue( undef ); }->detach; return $Q;
The problem is that seemingly at random, a (or more than 1) Net::OpenSSH SSH session will just terminate. This forces *all* existing Net::OpenSSH SSH sessions to terminate.
Wise Monks, any idea what's going on here to cause the premature exits? Many Thanks
In reply to Net::OpenSSH premature session termination by troy99
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |