I have mentioned below cmd on top of the script
exec > >(tee -a "$log_file") 2>&1
# (all remaining script part here)
The shell script is user interactive, so I want the inputs given by user are also to be redirected in same file. How this can be achieved?
script
utility. – Kusalananda Apr 08 '21 at 06:41script
utility, if it's not already installed, then runscript -c ./myshellscript.sh
(wheremyshellscript.sh
is the name of your script). You would not need theexec
command in the script. – Kusalananda Apr 08 '21 at 07:18script
example). – fra-san Apr 08 '21 at 08:56