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

Thank you for the response. May be if I explain you what I am trying to achieve here might help you to understand better my problem. I am executing a command in the spawned process(terminal), now when the command gets executed correctly then it gives output. Now if the output cannot be accomodated with in the current terminal size, it would display More... in the bottom of the output(like when we do ls | more). I will have to send the carriage return to the terminal through expect and get the complete output so that I can proceed. But my code is not working, it actually is breaking down before I send the carriage return to the terminal. I am seeing the output through a logfile ($exp_inst->log_file("$templog", "w");). Can you suggest if the code is fine and if yes then any other alternative to achieve this $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^3: Expect script doubt
by anonymized user 468275 (Curate) on Jun 27, 2005 at 11:36 UTC
    Any chance of putting the < code > < /code > tags round your code? I am afraid of missing something you put there otherwise.

    One world, one people

      <code> $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"; } ); <\code>
        </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.