The scripts that I was calling used the 'read' command to prompt the user for input like so:
These were interactive scripts but with a predictable pattern for input. Luck was on my side and I knew what each of these inputs should be while my script was being run. All I had to do was provide this input so that the external script would run as if it were a non-interactive script.
There are a number of ways to do the above, I went for something really simple, using echo and piping its output to the external script, like so:
Note that the echo string is split across multiple lines, this is completely OK to do. Also note that after my 3rd input value there is a new line, that is because I needed that final return character since the 'read' command in the external script would be expecting that.
The same approach worked when the external script prompted for a password using 'read -s' too.
The above approach worked really well in my case, but it's not suitable for every occasion. In more complex situations the 'expect' command would do a better job, but I'll leave that for another article.