in reply to Re^5: Expect script doubt
in thread Expect script doubt

$exp_inst->expect($timeout, ['-re' , $prompt, sub { my $fh = shift; $fh->send("$command\n"); } ] , [ timeout => sub { my_die "unable to get the prompt $prompt"; } ); ], sleep (2); $exp_inst->expect($timeout, [ qr'.*' , sub { $exp_inst->send("\n"); } ] , [ timeout => sub { print "Notting happening"; } ] );

Replies are listed 'Best First'.
Re^7: Expect script doubt
by anonymized user 468275 (Curate) on Jun 27, 2005 at 13:07 UTC
    The 12th line of this has an unexpected ')' so I was loth to make too many assumptions

    But apart from that my main first reaction is that you are mixing hash-style and list-style parameters in the actual parameter list to expect().

    In Expect.pm, expect() has rather flexible parameter parsing which looks happy to consume just anything you care to pass it.

    To be sure of how expect is using your parameters, you could use the debugger (-d at the end of the first line of your main program) and walk your way through how expect() deals with them (s to step, x to examine something).

    Compare the values being read in (wherever the expect function does a shift()) with what the expect() function is trying to do and ask yourself if they match up.

    -S

    One world, one people