While answering you are giving input via file descriptor 0 i.e. STDIN and the program is showing output on file descriptor 1 i.e. STDOUT. As you can see these two are wowking on different file descriptors and manipulating one should not hamper the operation of other.
Note that there is also file descriptor 2 i.e. STDERR normally used for showing error messages.
In you case run the script as:
./myscript.sh >~/script.out
Now you can provide input answers to the questions of the script via STDIN and the output of the program will be saved in ~/script.out
.
You can save the error also e.g. in another file:
./myscript.sh >~/script.out 2>~/script.err
The STDOUT will be saved in ~/script.out
and the STDERR will be saved in ~/script.err
.
You can save the output and error both in the same file:
./myscript.sh >~/script.all 2>&1
Now ~/script.all
will contain the outputs and error messages (if any) from myscript.sh
.