perl script that interacts with another (launches, enters input, etc.)

I have one script, call it [url removed, login to view], which prints the following output (everything inside square brackets "[]" is not really part of the output):


Hello world.

Let me think for five seconds...

[pauses for five seconds]

OK. Do you want to continue? Enter y or n.

[user has to enter "y" before the script can continue]

OK, thanks. Script doesn't actually do anything, so quitting now!


I want a second script that "harnesses" the first script -- it should launch the first script, read its output and print its output to me, and enter "y" when prompted so that the script keeps running. Also, the second script should print the output of the first script *as it's running* -- in other words, not wait until the entire script is finished before printing its output. (This is what the "wait five seconds" part is for -- I want to make sure that the second script prints the beginning output of the first script, then waits five seconds, etc. -- that the second script does not wait until the first script is entirely finished.)

Of course I'm going to modify the script to do more useful things after that, so it's nice if the code is readable :) I just don't know how to write the basic code that reads output of another script and interacts with it.

## Deliverables

The description covers basically everything that I want, just a few points to be clear on:

- before entering "y" in response to the first script, the second script should check that the prompt *exactly* matches the string "OK. Do you want to continue? Enter y or n.". I don't want the script to get some *other* prompt, and blindly respond "y" to something I didn't intend to answer.

- the script should verify that the very last line of output from the first script, matches one of several "expected" strings, like "OK, thanks. Script doesn't actually do anything, so quitting now!" or "Nothing to do". So that if anything else is produced as the last line of output, the second script outputs an error and quits.

- If anything unexpected happens (e.g. the first script generates a prompt that the second script was not expecting, or the last lines of output are something unexpected), the second script should quit with an error describing what went wrong and why it quit.

## Platform

This should run on CentOS 5 with Perl 5.8.8, although presumably the code will be portable enough to work with most Linux perl installations.

Habilidades: Perl, Instalación de scripts, Shell Script

Ver más: perl get, how to quit, how do you get linux, how do you do that, clear a string in c, and things like that, perl linux, write linux script, write test script, centos perl, script read, write 270 words, script script, brackets script, script modify install, response code error, check printing code, code perl script, perl output, perl script input, linux perl script, linux script seconds, linux keeps going, wait linux, printing script

Información del empleador:
( 128 comentarios ) Bellevue, United States

ID de proyecto: #2978395

1 freelancer está ofertando un promedio de $43 para este trabajo.


See private message.

$42.5 USD en 14 días
(100 comentarios)