$ ssh mylinux "tar -cmvz /tmp/mp3" | > /tmp/mp3.tgz
####
#!/usr/bin/perl -w
use diagnostics;
#use strict;
use Net::SSH::Perl;
use IO::Handle;
open(FOUT, ">/tmp/test.out");
open(FERR, ">/tmp/test1.err");
##########################
$params{'protocol'} = '2';
$params{'port'} = '22';
$params{'debug'} = 'true';
$params{'interactive'} = 'false';
$params{'compression'} = 'false';
$params{'identity_files'} = [$ENV{HOME}."/.ssh/id_rsa"];
$params{'options'} = ["RSAAuthentication yes",
"PasswordAuthentication no",
"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);
####
#!/usr/bin/perl -w
use diagnostics;
#use strict;
use IO::Handle;
STDOUT->autoflush(1);
print(STDERR "TAR START...\n");
system("tar -cmvzf /tmp/mp3.tgz /home/op/mp3");
print(STDERR "TAR END.\n");
####
Apr 27 16:22:38 mylinux sshd[32703]: debug2: channel 1: rcvd adjust 18039
Apr 27 16:22:38 mylinux sshd[32703]: debug2: channel 1: rcvd adjust 31113
Apr 27 16:22:38 mylinux sshd[32703]: debug1: need rekeying
Apr 27 16:22:38 mylinux sshd[32703]: debug1: SSH2_MSG_KEXINIT sent
Apr 27 16:22:38 mylinux sshd[32703]: debug2: channel 1: rcvd adjust 18039
####
mylinux: channel 1: window 1655 sent adjust 31113
mylinux: channel 1: window 14729 sent adjust 18039
mylinux: channel 1: window 1655 sent adjust 31113
mylinux: Warning: ignore packet type 20
mylinux: channel 1: window 14729 sent adjust 18039