in reply to Net::Telnet::Cisco usage

I've never used that particular module. But I have used Net::Telnet a bit, and I don't believe the command output works in quite that way. Here is an exert from a script I've got to change passwords for people. Hope it helps, about the only thing of note is $PASSWD is my scalar it contains the path to passwd depending on if its going to solaris, irix, bsd, or linux.
The line I would point you towards is my($pre,$match) = $shell->waitfor(Match => '/Incorrect password/', this gets the output from the command so I can play with it.
open(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; }
and in case you want it here is telnet login
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 }
I wish I could offer more assistance.

jcpunk