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