Hello everyone, I'm trying to cycle through a list of servers using Net::Telnet and run some commands. My problem is this: half the servers use one pair of username/password's and the other half use a different pair of username and password's. My question: how can I get my code to default to a second pair of username/password's if the first set fails. I am trying to use the following:
$prev = $t->errmode("return"); $t->login($first_user_name, $first_password) or print "Login failed: @{[ $t->errmsg() ]}\n"; $t->waitfor(String => 'login: ', Timeout => 30); $t->login($second_user, $second_password) or print "Login failed: @{[ $t->errmsg() ]}\n"; The above does not seem to work. The second login attempt yields the errmsg: Logging failed: Timed-out waiting for the login prompt. What I can't understand is (login: ) is the login prompt (yet it still doesn't work). I'm using the dump_log method ($fh = $t->dump_log($logfile)) to verify that 'login: ' is the correct prompt. I've also tried using Match but it yields no success: ex: $t->waitfor(Match => '/login:\W*/i'). Am I using the waitfor call incorrectly? Does someone know of a better way to accomplish what I'm trying to do? Any help/direction would be very much appreciated. Thanks Chris