Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Venerable Monks,

I am trying to collect the ouptut of a command that is run after logging in to a NAS Array through SSH.

The command,  nas_server -list gives the statuts of the NAS Array. I am trying the following script to do it. For some reason, its not capturing the actual command output of the command in the  @output array even after stating  my @output = $chan->exec('nas_server -list'); It seems to capture the value 1, which I presume corresponds with the successful status of the command being executed.

Here is the complete script

#!/usr/bin/perl; use Modern::Perl; use 5.014; use Net::SSH2; my $nasip = '127.0.0.1'; #Actul IP is different. my $user = 'user'; my $pass = 'passwd'; my $ssh = Net::SSH2->new(); $ssh->debug(1); say "Connecting to $nasip"; $ssh->connect("$nasip") || warn "$!"; $ssh->auth_password("$user","$pass"); my $chan = $ssh->channel(); my @output = $chan->exec('nas_server -list'); say "output is: @output"; $chan->close();

And here is the output. The IP given in the example is 127.0.0.1, but I am actually using a different IP to login to the NAS Array

Connecting to 127.0.0.1 libssh2_channel_open_ex(ss->session, pv_channel_type, len_channel_type +, window_size, packet_size, ((void *)0) , 0 ) -> 0x11353dc output is: 1 Net::SSH2::Channel::DESTROY Net::SSH2::DESTROY object 0x9b745c

Firstly, I know very rudimentary Perl and I am back here after almost a year, so if any mistakes in the script above please do forgive me. Thanks a lot to vdubjunkie, because If not for his node Net::SSH2 woes, I wouldn't even have written the above script.

The NAS Array (Network Attached Storage Array) is an EMC Storage Array - NS960. I am running the script from a Windows 2003 host on which Perl Version 5.14.2 is installed.

Kindly request you please guide me to a site where a detailed tutorial for the Net:SSH2 Module is given. I did go through the perldoc, also googled, but didn't find anything that I could understand. :(

Perlpetually Indebted To PerlMonks


In reply to Unable to store the command output from Net::SSH2. Please help. by perl514

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!
  • 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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (14)
    As of 2015-07-01 17:20 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (13 votes), past polls