and in case you want it here is telnet loginopen(STDERR, ">&STDOUT"); # changes STDERR to STDOUT, lets the p +assword thing actually work.... I think if ($METHOD eq 'telnet') { telnet_login($username, $password, $host, \$shell); # calls ou +t to temerity_lib.pl for the generic telnet log in process. NOTE: $shell is passed by referance # perform the actions we need to accomplish $shell->print($PASSWD); # start changing the password $shell->waitfor('/password:/i') or report_error("password","No + password prompt found");; # make sure it worked $shell->print($password); # send your login password my($pre,$match) = $shell->waitfor(Match => '/Incorrect passwor +d/', Match => '/New password:/') +; # make sure it worked $match =~ /New/ or report_error("password","Not prompted for n +ew password");; $shell->print($new_password); # send new password ($pre,$match) = $telnet->waitfor(Match => '/Bad password/', Match => '/Re-enter new passw +ord:/'); # make sure it worked $match =~ /Re-enter/ or report_error("password","New password +rejected"); $shell->print($new_password); # send new password again $shell->waitfor('/changed/i') or report_error("password","New +password rejected"); # make sure it worked $shell->close; }
sub telnet_login # opens a telnet session to "host" { use Net::Telnet; # initialize the telnet module my ($username, $password, $host, $shell) = @_; # takes function arguments and stores them into appropriate variab +les $$shell = new Net::Telnet ('Timeout'=>'7', 'Errmode'=> sub { report_error("telnet" +,"Username or Password failed"); }, 'Prompt'=> '/.*([\$#\%>~]|\@\w~\$|\\\[\ +\e\[0m\\\] \[0m)\s?/' ); # initalizes a telnet object sets a prompt to expect sets a timeou +t sets error-checking $$shell->open(Host=>$host); # opens the object $$shell->login($username,$password); # login to the telnet sessio +n }
In reply to Re: Net::Telnet::Cisco usage
by jcpunk
in thread Net::Telnet::Cisco usage
by chimni
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |