use strict; use warnings; use Net::OpenSSH; use Net::Telnet; $Net::OpenSSH::debug = -1; my $promptEnd = '/\w+[\$\%\#\>]\s{0,1}$/o'; my $timeout = 60; my $ssh = Net::OpenSSH->new('your.ciscodevice.here', user => 'johndoe', password => 'secretpass', kill_ssh_on_timeout => 1, timeout => $timeout); # stderr_to_stdout was required to get Net::Telnets waitfor() to work my ($fh, $pid) = $ssh->open2pty({stderr_to_stdout => 1}); my %params = ( fhopen => $fh, prompt => $promptEnd, timeout => $timeout, errmode => 'return', telnetmode => 0, cmd_remove_mode => 1, output_record_separator => "\r", ); my $conn = Net::Telnet->new( %params ); my @lines = $conn->cmd("show tech"); print @lines;