shell script for a partial control over inputs to an external program
I've a software written by a third party (for linux distros, Ubuntu to be precise). This program executes while asking for user input (via stdin) at various stages of its running.
Now, a few of these stages/steps can be automated because the user input required is always the same. The other stages have varying inputs that depend on the outcome of some measurements from the previous stages; and so, have to be entered on-the-fly.
To elaborate, one can roughly describe the running of the program in this fashion:
Step0 - User input fixed
Step1 - User input fixed
Step2 - User input variable
Step3 - User input fixed
Step4 - User input fixed
Step5 - User input fixed
Step6 - User input fixed (and one can choose here either to return to Step3 or proceed to Step7)
Step7 - User input fixed
Step8 - User input variable
Step9 - User input variable
So, I wish to automate the Run portion from Step3 to Step6 now... the picture I've in my mind is of a shell script which runs in the background, parsing the stdout of the program (mainly textual in nature) and lets the program start in the usual way for the Init steps i.e. waits for the user to enter the input via stdin for Step0 to Step2.
From then on, it runs for say 5000 times, but now picking the input parameters from a file instead (created accordingly, to run Step3 to Step6 in a loop for 5000 times) and then at the 5001st instant, chooses to proceed to Step7.
I had had some exposure to linux shell programming quite long ago, but that seems enough to convince me that coding the above shouldn't be very hard ;-) but I look forward to your tips, pointers and suggestions on how to do it in the best possible way.
Thanks very much in advance,