If I have a very simple shell script like this:
echo "thing 1?"
read input1
echo $input1
echo "thing 2?"
read input2
echo $input2
How can I call the script/command with only 1 of the user inputs provided, while allowing any subsequent reads calls to prompt my terminal? I have been doing printf "foo\n" | sh myscript.sh
which does pass in the 1st read, but then when it get's to the 2nd, instead of prompting the user the script just exits.
Use cat
to read from standard input.
( echo foo; cat ) | sh myscript.sh