sub start_login { open(STDERR, ">&STDOUT"); my $telnet; my $PASSWD = "/bin/passwd"; telnet_login($username,$password,$host,\$telnet); #custom login function $telnet->print('passwd'); $telnet->waitfor('/password:/i') or report_error("ERROR","No password prompt found");; $telnet->print($password); my($pre,$match) = $telnet->waitfor(Match => '/Incorrect password/', Match => '/New password:/'); $match =~ /New/ or report_error("ERROR","Not prompted for new password");; $telnet->print($new_password); ($pre,$match) = $telnet->waitfor(Match => '/Bad password/', Match => '/Re-enter new password:/'); $match =~ /Re-enter/ or report_error("ERROR","New password rejected"); $telnet->print($new_password); $telnet->waitfor('/changed/i') or report_error("ERROR","New password rejected"); telnet_close(\$telnet); #gentially close this object, it has been nice to us we hope $success = 1; }