I have a script which guides users through the installation of my software and I want to write a log file in case something bad happens and the user needs support.
The script looks like this:
while true; do
echo "This script will help you with the installation. Do you wish to proceed?"
echo "(1) Yes"
echo "(2) No"
read proceed
case $proceed in
1 ) break;;
* ) echo "Aborting."; exit 8;;
esac
done
unset proceed
I then run it by using ./install.ksh | tee /var/log/myinstall.log and everything works just fine, but the user input to the question is not logged.
When I add echo $proceed after the read command, it is written to the log but displayed twice, like that:
This script will help you with the installation. Do you wish to proceed?
(1) Yes
(2) No
1 #this is the input which is not written to the log
1 # this is the echo which is written to the log
My question is now how I could either suppress the output of the read command or how I could write the echo only to the file but not to STDOUT?
echo "You chose $proceed, continuing"?