I'm trying to write a simple telnet script to log into a router and the problem I'm encountering is that the script times out at "$telnet->login($username, $password);". Is it because I am expecting the wrong prompt?
#!/usr/bin/perl -w
#program to telnet to remote host
use Net::Telnet();
$telnet = Net::Telnet->new
(
Timeout => 10,
Prompt => '/Username: /'
);
$username = "joesmoe";
$password = "xxxxx";
$telnet->open ("x.x.x.x"
;
$telnet->login($username, $password);
$telnet->cmd ("show version"
;
@output= $telnet->cmd("show version"
;
$telnet->cmd("exit"
;
print $output;
#!/usr/bin/perl -w
#program to telnet to remote host
use Net::Telnet();
$telnet = Net::Telnet->new
(
Timeout => 10,
Prompt => '/Username: /'
);
$username = "joesmoe";
$password = "xxxxx";
$telnet->open ("x.x.x.x"
$telnet->login($username, $password);
$telnet->cmd ("show version"
@output= $telnet->cmd("show version"
$telnet->cmd("exit"
print $output;