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
my $nasip = '127.0.0.1'; #Actul IP is different.
my $user = 'user';
my $pass = 'passwd';
my $ssh = Net::SSH2->new();
say "Connecting to $nasip";
$ssh->connect("$nasip") || warn "$!";
my $chan = $ssh->channel();
my @output = $chan->exec('nas_server -list');
say "output is: @output";
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::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
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- 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
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] |