#!/usr/bin/perl -w use strict; use diagnostics; #use strict; use Net::SSH::Perl; use IO::Handle; open(FOUT, ">/tmp/test.out"); open(FERR, ">/tmp/test1.err"); ########################## my ($sshconn, $ssherr, $sshexit); my %params = ( protocol => 2, port => 22, debug => 'true', interactive => 'false', compression => 'false', identity_files => [$ENV{HOME}."/.ssh/id_rsa"], options => [ "RSAAuthentication yes", "PasswordAuthentication yes", "ConnectTimeout 10", "BatchMode yes", "FallBackToRsh no", "RhostsAuthentication no", "RhostsRSAAuthentication no", "KeepAlive yes"] ); eval { if ( $sshconn = Net::SSH::Perl->new("localhost", %params)) { $sshconn->login('op'); $sshconn->register_handler("stdout", sub { my($outchannel, $outbuffer) = @_; print(FOUT $sshconn->type); }); $sshconn->register_handler("stderr", sub { my($errchannel, $errbuffer) = @_; print(FERR $errbuffer->bytes); }); ($ssherr, $ssherr, $sshexit) = $sshconn->cmd("/tmp/bufile.pl"); $sshconn->cmd("exit"); } }; if ( $@ ) { warn $@; } close(FOUT); close(FERR);