perl514 has asked for the wisdom of the Perl Monks concerning the following question:
Respected Monks,
I am trying a different implementation of a script I had written earlier for checking EMC Celerra NAS Arrays (Uploaded in Cool Uses Of Perl Section). I wanted to check a different command and stuff doesn't seem to work. In order to reduce the error checks to a bare minimum, I wrote a simple script as given below. I have given the loopback IP and a fake username password below but in the script, I am using the correct one. I have also ssh'd into the NAS Array and ran the command from command prompt and that works fine.
#!/usr/bin/perl use warnings; use strict; use Net::SSH2; my $nasip= "127.0.0.1"; my $username = "username"; my $password = "password"; my $ssh2 = Net::SSH2->new(); $ssh2->connect("$nasip") || die "Cant connect to $nasip - $!"; $ssh2->auth_password("$username","$password") || die "Username/Passwor +d not right"; my $chan = $ssh2->channel(); $chan->blocking(0); sleep 10; $chan->exec('nas_server -list') or die "Cannot run the command - $!.$^ +E."; print while (<$chan>);
If I run the script above, I get the following ouptut:
C:\plscripts>perl newmon.pl Cannot run the command - .A non-blocking socket operation could not be + completed immediately. at newmon.pl line 16.
Sorry if my question appears stupid, but is the Net::SSH2 capable of running a command with a space in it? The command I am running in the script this time is nas_server -list and earlier it was /nas/sbin/getreason
.As can be seen, there's a space between "nas_server" and "-list". I googled up and got to know that the Error I am getting is something to do with a Windows related socket error, but if so, how come I dont get the error when I run the /nas/sbin/getreason command? I have also ssh'd into the NAS Array and ran the command from command prompt and that works fine.Please let me know if I am going wrong somewhere. This script is running on Windows Server 2003 with DWIM Perl 5.14.
Perlpetually Indebted To PerlMonks
http://dwimperl.com/windows.html is a boon for Windows.use Learning::Perl; use Beginning::Perl::Ovid; print "Awesome Books";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Error - A non-blocking socket operation could not be completed immediately.
by BrowserUk (Patriarch) on Mar 06, 2013 at 14:33 UTC | |
by perl514 (Pilgrim) on Mar 06, 2013 at 17:08 UTC | |
by BrowserUk (Patriarch) on Mar 06, 2013 at 19:46 UTC | |
Re: Error - A non-blocking socket operation could not be completed immediately.
by zentara (Archbishop) on Mar 06, 2013 at 20:12 UTC | |
by perl514 (Pilgrim) on Mar 07, 2013 at 14:10 UTC |