#!/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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.