@seiwer-tail

Как предотвратить закрытие скрипта при выполнении команд?

Привет всем! В общем пишу свой скрипт установщик для мобильный устройств и заметил такую странность что при выполнении sudo команд скрипт просто умирает и закрывается

Как это исправить?

(кусок кода где это происходит

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"


Смерть скрипта происходит после этой команды: exec sudo mount -o remount, rw /
Система просит пароль, я его ввожу команда выполняется и скрипт не продолжает работу а меня просто выкидывает в саму консоль (то есть скрипт закрывается) и мне надо как то заставить скрипт не закрываться и продолжить выполнение скрипта дальше

Зараннее спасибо
  • Вопрос задан
  • 97 просмотров
Решения вопроса 1
vaut
@vaut
Вы не правильно используете exec, он тут вообще не нужен.

$ 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.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
19 апр. 2024, в 05:01
999999 руб./за проект
19 апр. 2024, в 03:52
1000 руб./за проект
19 апр. 2024, в 03:01
1000 руб./за проект