open(STDERR, ">&STDOUT"); # changes STDERR to STDOUT, lets the password thing actually work.... I think if ($METHOD eq 'telnet') { telnet_login($username, $password, $host, \$shell); # calls out 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 password/', Match => '/New password:/'); # make sure it worked $match =~ /New/ or report_error("password","Not prompted for new password");; $shell->print($new_password); # send new password ($pre,$match) = $telnet->waitfor(Match => '/Bad password/', Match => '/Re-enter new password:/'); # 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 variables $$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 timeout sets error-checking $$shell->open(Host=>$host); # opens the object $$shell->login($username,$password); # login to the telnet session }