in reply to Am I using Net::SSH2 the wrong way?
Is there any reason for setting the connection in non-blocking mode?
In any case, you can try using Net::SSH::Any instead of Net::SSH2. It can run on top of Net::SSH2 and provides a higher API, making most tasks easier to accomplish. For instance:
use Net::SSH::Any; my $ssh = Net::SSH::Any->new($ipaddr, user => username, password => $p +assword); $ssh->error and die "Unable to connect to $ipaddr: " . $ssh->error; my @lines = $ssh->capture('/nas/sbin/getreason'); for (@lines) { next if /10 - slot_0 primary control station/; if (/contacted$/) { print $mailfh "DM is OK: $_\n"; } else { print $mailfh "POSSIBLE DM FAILURE:Please check $ipname ($ipaddr): + $_ POSSIBLE DM FAILURE:\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Am I using Net::SSH2 the wrong way?
by perl514 (Pilgrim) on Jan 18, 2013 at 12:38 UTC | |
by salva (Canon) on Jan 18, 2013 at 14:37 UTC | |
by perl514 (Pilgrim) on Jan 18, 2013 at 18:25 UTC |