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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |