#!/usr/bin/perl use Net::SSH::Perl; my ($user,$host,$password)=split(/[\@:]/,$ARGV[0]); my $cmd="wc"; my %params=('debug',1 ); my $ssh = Net::SSH::Perl->new($host,%params); $ssh->login($user, $password); my $intext="X" x 10631; # 10631 and bigger fails. # after the patch, 10583 doesnt work, 10582 does. my ($stdout, $stderr, $exit) = $ssh->cmd($cmd,$intext); print "remote output is $stdout\n"; print "remote exit status is $exit\n"; print "remote stderr is $stderr\n"; #### #!/usr/bin/perl # use Net::SSH2; use strict; my ($host,$user,$password); ($user,$host,$password)=split(/[\@:]/,$ARGV[0]); my $cmd; $cmd="wc"; #$cmd="date"; #$cmd="perl -e \"print 'Y'x100000\""; my $ssh = Net::SSH2->new(); print STDERR "ssh created\n"; $ssh->connect($host) or die "Unable to connect Host $! \n"; print STDERR "ssh connected \n"; $ssh->auth_publickey($user, '/home/mark/.ssh/id_rsa.pub', #testing on localhost '/home/mark/.ssh/id_rsa' ) or die "Unable to login $!\n"; print STDERR "ssh authenticated\n"; my $intext="X" x 100000; print STDERR "cmd is $cmd\nintext length is ".length($intext)."\n"; my $chan = $ssh->channel() or die "channel creation failed $!"; $chan->blocking(0); binmode($chan); #$chan->shell(); $chan->exec($cmd); print $chan $intext; my $n=0; # while ($n=read($chan,$buf,512)) # while ($n=$chan->read($buf,512)) #{ # print STDERR "$n bytes read\n"; #} my $exit; while (<$chan>) { print $_; $n+=length($_); } $chan->close; $exit=$chan->exit_status(); print "remote exit status is $exit bytes returned is $n bytes\n";