#!C/Perl -w use strict; use warnings; use Net::Telnet; my $telnet = new Net::Telnet ( Timeout=>10, Binmode=> 1, telnetmode => 0, Input_log=>"input.log", Dump_log=>"dump.log", Output_log=>"output.log", Errmode=>'die', Prompt=>'/(?m:^[\w.-]+\s?(?:\(config[^\)]*\))?\s?[\$#>]\s?(?:\(enable\))?\s*$)/'); print "I am opening a connection\n"; $telnet->open('x.y.z.x'); print "i established a connection\n"; $telnet->waitfor('/Username: $/i'); $telnet->print('xxx'); print "i entered username\n"; $telnet->waitfor('/Password: $/i'); $telnet->print('yyy'); print "i entered password\n"; $telnet->waitfor('/.*$/i'); print $telnet->cmd('show platform'); print 'I am done executing the show command'; $telnet->close();