I've checked the result of $login_output as well, and whether the ssh is successful or not, it always returns the same value. I have a list of 3 servers to use while I'm testing this, two work fine, and the 3rd fails, but all return values and login_output is exactly the same in every iteration.

I have read through the documentation probably dozens of times, and have tried every variation of what I've seen there, with no success each time. I've copied the code verbatim and still have same issue. Another site I found was checking for $@, but of course that value was useless, and the return value is always 1 for any server.

According to what I read, using eval (which I have never done in Perl before) is what populates the $@ variable, but again that apparently was not the case. I'll give an example of my list and the output of what I have below:

Server list =
belle (valid) everglades (valid) hugger (not valid)
(Meaningful) Code:
my $ssh = Net::SSH::Expect->new ( host => "$current_server", user => "$user", raw_pty => 1 ); # removed the eval $login_output = $ssh->run_ssh(); print("$current_server \$! = $!\n"); print("Login output for $current_server = $login_output\n"); ($ssh->read_all(2) =~ />\s*|$\s*\z/) or die "where's the remote prompt +?"; $ssh->exec("stty raw -echo");
And my output:
belle $! = Illegal seek Login output for belle = 1 belle Dump device: /dev/zvol/dsk/rpool/dump (dedicated) everglades $! = Illegal seek Login output for everglades = 1 everglades Dump device: /dev/md/dsk/d101 (swap) hugger $! = Illegal seek Login output for hugger = 1 SSHProcessError The ssh process was terminated. at ./script.pl line 39

As you can see this is a script to monitor the dump device on Solaris boxes, and it works fine on the first two. Still working out why I'm getting the Illegal Seek messages (which is why I temporarily have the -w flag turned off -- but that's another issue).

Thanks!
-Tim

In reply to Re^4: Problem with Net::SSH::Expect on unavailable hosts by sierpinski
in thread Problem with Net::SSH::Expect on unavailable hosts by sierpinski

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.