#!/usr/software/bin/perl -w use strict; use warnings; use Net::SSH2; my $ssh = Net::SSH2->new(); $ssh->debug(0); my $bigcmd = "priv set diag; wafl_susp -w"; my @array; $ssh->connect("10.61.92.10",22); my $pass = 'P@ssw0rd'; $ssh->auth(username => 'root', password =>$pass ); if($ssh->auth_ok()) { runcmd(my_channel($ssh), "$bigcmd"); } print "----------------------------------------------\n"; foreach (@array) { print "$_\n"; } sub runcmd { my ($channel, $command) = @_; @array = <$channel>; $channel->exec($command);# or die $@ . $ssh->error(); my $buff; while(!$channel->eof()) { my $buff; $channel->read($buff, 1024); } my $rc = $channel->exit_status(); $channel->close(); return $rc; } sub my_channel { my $ssh = shift(@_); my $chan = $ssh->channel('session'); $chan->blocking ( 0 ); $chan->flush(); $chan->ext_data('merge'); return $chan; }
results in
@cycsnane01:( ~/_Scripts/) $ ./waflsusp.pl ----------------------------------------------
In reply to Re^4: redirect stdout into hash
by doctorspears
in thread redirect stdout into hash
by doctorspears
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |