my $ssh = Net::SSH::Expect->new ( host => "$serverlist[$host]", user => "$user", raw_pty => 1, restart_timeout_upon_receive => 1, timeout => 6, ssh_option => " -x", ); # Validate that we have a successful ssh connection $login_output = $ssh->run_ssh() or die "Couldn't start ssh process, error $!\n"; sleep(1); my $ret; my $rc1 = eval{$ret = $ssh->read_all(12);}; unless($rc1) { open(NOCON,">>$NOCONNECT"); print NOCON "$serverlist[$host] - Could not connect -- skipping.\n"; close(NOCON); $pm->finish(0); # Couldn't connect to this one, skip to next server in main loop } my $rc = eval{( $ret =~ />\s*|$\s*\z/) or die "where's the remote prompt?";}; if($rc) { if($ret =~ m/[Pp]assword:/) { # print("Server asking for password, key not installed.\n"); open(NOCON,">>$NOCONNECT"); print NOCON "$serverlist[$host] - Asking for password -- skipping.\n"; close(NOCON); $pm->finish(0); # Couldn't connect to this one, skip to next server in main loop } } $ssh->exec("stty raw -echo"); # Start issuing the commands to check