On Tue, Mar 17, 2009 at 11:23, socrtwo <socr...@gmail.com> wrote: > 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. snip
Depending on how cakcmd is reading the return this may work: my $pid = open my $cakcmd, "-|", "/path/to/file/cakcmd", @cakcmd_arguments or die "could not run cakcmd: $!"; print $cakcmd "\r"; waitpid $pid; #wait for cakcmd to finish running If you need to both write to and read from the process you will need to use IPC::Open2[1] or IPC::Open3[2] (depending on whether you care about STDERR or not). You may also find the Expect[3] module helpful. 1. http://perldoc.perl.org/IPC/Open2.html 2. http://perldoc.perl.org/IPC/Open3.html 3. http://search.cpan.org/dist/Expect/Expect.pod -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/