Perl script pauses twice - how do I make it continue without getting carriage returns...

  • Thread starter Thread starter socrtwo
  • Start date Start date
S

socrtwo

Guest
...from the keyboard? This is a cross post from my question in Mahalo Answers and Google Perl Beginners Group.

I am using the executable cakecmd unzipper in a Perl script. Normally when cakcmd is executed outside of Perl and it's done it's work it pauses and one has to hit enter to return to the prompt.

How can I program Perl so that it enters the carriage return for me? Printing a carriage return doesn't work, it just adds an additional line between prompts. At this point I call cakecmd twice, and so to complete my script I have to hit the Enter key twice within my Windows CMD console.

I got a promising response from Perl Beginners Google Group that suggest I use the CPAN Perl Module called Expect, however I am unclear how to use it. How can I tell Perl to use Expect, to look for a no time limit pause and then execute a carriage return?

Thanks
Thanks for the first answer. It doesn't work using either the system or the exec function. The system function gives me errors, the exec works but still has the same pauses requiring carriage returns. The parameter < ^M, doesn't seem to make a difference.
 
Use a pipe, instead. You are calling cakcmd, maybe with

system("cakcmd");

Try making the call

system ( "cakcmd < ^M");

So you are explicitly telling the shell to call "cakcmd" with an input of control-M.

Edit: The sequence "< ^M" is not a parameter, it is an input to the cakcmd command of a new line. If you are editting in Emacs, ^M is done as "control-Q control-M" to put a quoted control-M into the text.
 
Back
Top