my $device = Net::Telnet->new(Timeout => 10, Errmode => 'return'); $device->open(Host => &SSH_HELPIP, Port => &SSH_HELPPORT); if(!$device) { print "Unable to connect to SSH Helper\n" if ($var->{debug}); return undef; } my ($prematch, $match) = $device->waitfor('/:/'); #print "$prematch and $match
\n"; if ($prematch =~ /login/) { $device->print(&SSH_ID); } else { print "Timeout waiting for login prompt on SSH Helper - $prematch and $match\n" if ($var->{debug}); return undef; } my ($prematch, $match) = $device->waitfor('/:/'); #print "$prematch and $match
\n"; if ($prematch =~ /Password/) { $device->buffer_empty(); $device->print(&SSH_PW); } else { print "Timeout waiting for password prompt on SSH Helper\n" if ($var->{debug}); return undef; } $device->waitfor('/\$/'); $device->print('ssh -l testid ' . $ip); my ($prematch, $match) = $device->waitfor('/\?|word:/'); if ($prematch =~ /re you sure you want to continue connecting/) { $device->print("yes"); my ($newpmatch, $newmatch) = $device->waitfor('/word:/'); if ($newpmatch =~ /pass/) { $device->print(&PWD()); } } else { if ($prematch =~ /pass/) { $device->print(&PWD()); } } return $device;