Well, just letting some time elapse in order to ensure that all the data has arrived is not a reliable approach.
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";
}
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|