I am new to scripting. Facing a problem in trying to do the following. Please help.
My C++ program runs in a while loop, receives commands from the user on a prompt, and executes them. I want to automate this process.
Sample execution
$ ./my_tool
my_prompt> command1 arg1 arg2
result: abc
my_prompt> command2 arg3
result: xyz
my_prompt> command3 abc xyz
result: my_result
my_prompt> exit
$
Now, I want to have a file, input.txt, which will have
command1 arg1 arg2
command2 arg3
command3 <abc> <xyz>
exit
Execution of the script will be something like
./run ./my_tool input.txt
How do I write a simple bash script to achieve this? I will have at least 20 commands.
If I don't have command3, that is, all input parameters are predetermined, then how can I proceed?
Sorry if this is really simple - I am not able to figure out.
Thanks and regards, SB