my $sshap = Net::SSH::Expect->new ( host => $apip, user => 'Cisco', ssh_option => '-o StrictHostKeyChecking=no', raw_pty => 1, timeout => 5 ); if($sshap->run_ssh()){ $sshap->waitfor ('Password:', 7) or warn "SSH problem: 'Password' not found after 7 second"; $sshap->send ('Cisco'); $sshap->waitfor ("$ap\>", 3) or warn "SSH problem: $ap\> not found after 3 second"; $sshap->send ('en'); $sshap->waitfor ('Password:', 3) or warn "SSH problem: 'EN Password' not found after 3 second"; $sshap->send ('Cisco'); $sshap->waitfor ("$ap\#", 3) or warn "SSH problem: $ap\# not found after 3 second"; $sshap->send ('show ip interface brief'); while (defined ($line = $sshap->read_line()) ) { print "$line\n" } $sshap->send('exit'); $sshap->close(); } else { print "$apname Could not open SSH\n"; }