Answer the question
In order to leave comments, you need to log in
How to prevent the script from closing when executing commands?
Hi all! In general, I am writing my installer script for mobile devices and noticed such a strange thing that when executing sudo commands, the script just dies and closes
. How can I fix this?
(a piece of code where it happens
echo "What would you like to do?"
echo "i - Install Anbox "
echo "q - What problems can I face after installation "
echo "e - exit "
echo " "
echo " "
read -p "answer: " menu
case $menu in
i) echo " Preparatory work will be done now. The system will now ask for a password to install the screenfetch and android-tools package"
echo " "
read -p "Press enter to start preparation" prepare
exec sudo mount -o remount, rw /
exec sudo apt install -y screenfetch anbox-ubuntu-touch android-tools-adb
exec cd /home/phablet/
exec mkdir /home/phablet/anbox-data
echo "Excellent! Let us ask a couple of questions before starting the installation to start the installation"
echo "Don't worry, the questions will be easy"
Answer the question
In order to leave comments, you need to log in
You are not using exec correctly, it is not needed here at all.
$ man bash
exec [-cl] [-a name] [command [arguments]]
If command is specified, it replaces the shell. No new process
is created. The arguments become the arguments to command. If
the -l option is supplied, the shell places a dash at the begin‐
ning of the zeroth argument passed to command. This is what
login(1) does. The -c option causes command to be executed with
an empty environment. If -a is supplied, the shell passes name
as the zeroth argument to the executed command. If command can‐
not be executed for some reason, a non-interactive shell exits,
unless the execfail shell option is enabled. In that case, it
returns failure. An interactive shell returns failure if the
file cannot be executed. If command is not specified, any redi‐
rections take effect in the current shell, and the return status
is 0. If there is a redirection error, the return status is 1.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question