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;