I'm using Perl to automate a script on some Cisco routers. The basic implementation is that it connects to a given list of routers, one after the other and collects the needed information. Each time the script connects to a new router it requests a password, which is the same for all routers.
I have the following code to capture the password request and input the password:
$session->expect(5,
[ 'password:' => sub {
$session->send("$password\r");
#exp_continue;
}]);
The problem is that sometimes the password isn't accepted the first time, for whatever reason. Is there a way to repeat the above code until the password is accepted?