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

</code> to terminate the code -- some of the code is either getting lost or is causing the problem because of a shifted actual parameter list but until I see an unscrambled version of the code I can't be sure of this.

Replies are listed 'Best First'.
Re^6: Expect script doubt
by Anonymous Monk on Jun 27, 2005 at 12:41 UTC
    $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"; } ] );
      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