From: Blackstone, J. D. <jda...@ci...> - 2002-04-17 19:56:49
|
> The following code is close but how do I continue after > logging in with username/password and execute a > series of command? > > If I put qr/$prompt/ > > $exp->expect($timeout,, sub... > commands > > It goes into an endless loop. Don't use exp_continue. Use a separate $exp->expect for each step. > > ----------- Start perl code > [ qr/username: /i, sub { my $self = shift; > $self->send("$username\n"); > exp_continue; }], > [ qr/password: /i, sub { my $self = shift; > $self->send("$password\n"); > exp_continue; }], > $shell_prompt); > ----------- Start perl code $exp->expect(qr/username: /i); $exp->send("$username\r"); $exp->expect(qr/password: /i); $exp->send("$password\r"); $exp->expect("$shell_prompt"); ... This should work, unless there's a particular reason you wanted to use one expect statement for them all (perhaps the username and/or password prompts are optional?). jdb |