$PASSWD = "/bin/passwd"; $telnet->cmd($PASSWD) or report_error("ERROR", "No password prompt found, contact Information Technologies: "); $telnet->waitfor('/password: ?$/i') or report_error("ERROR", "No password prompt found, contact Information Technologies: "); $telnet->print($password); $telnet->waitfor('/new password: ?$/i') or report_error("ERROR", "No password prompt found, contact Information Technologies: "); $telnet->print($new_password); $telnet->waitfor('/new password: ?$/i') or report_error("ERROR", "No password prompt found, contact Information Technologies: "); $telnet->print($new_password); $telnet->waitfor('/changed/'); ..... sub report_error { #give out std error message and write error to a log file }