My question is an enhancement for the following one passing arguments to an interactive program non interactively.
I am using a script which will ask me to choose an option from the list:
1 - ABC
2 - CDE
3 - EFG
I know which option I should choose based on letters, but script expect to provide a number.
Is there any way to do it in a non-interactive way? I mean to pass a "parameter" which will find a number based on the given letters.
[EDIT 1]
I see that my description is not very clear, therefore I am adding a test case.
I have a script: test.sh
. It is the interactive script, so question are asked when I run it:
./test.sh
Are you sure you want to run it? (y/n): y
Please choose option:
1 - ABC
2 - CDE
3 - EFG
1
To run this script in a non-interactive way I am using:
echo "y
1" | test.sh
The problem is that when I am running the script I don't know which number is assigned to the option that I would like to choose.