0

I have a very important project that needs a menu to execute some bash scripts. What happens is that this code works fine but doesn't get back to the menu after executing one of the options. Can you help me please?

#!/bin/bash
PS3='Escolha uma opção: '
options=("Cria condutor" "Cria passageiros" "Lista negra" "Atualiza condutores" "Stats" "Sair")
clear
select opt in "${options[@]}";
do
case $opt in
    "Cria condutor")
    echo "Insira o número de estudante: "
    read nestudante
        echo "Insira o primeiro e Último nome: "
    read nome
            echo "Insira a sua turma: "
    read turma
            echo "Insira o número de telemóvel: "
    read ntelemovel
            echo "Insira o seu e-mal: "
    read email
            echo "Insira o tipo de viatura (carro ou mota): "
    read tipo
            echo "Insira a marca do veículo: "
    read marca
            echo "Insira a matrícula: "
    read matricula
    exec ./cria_condutor.sh $nestudante $nome $turma $ntelemovel $email $tipo $marca $matricula
    break;;

    "Cria passageiros")
        exec ./cria_passageiros.sh
        ;;

    "Lista negra")
        exec ./lista_negra.sh
        ;;

    "Atualiza condutores")
        exec ./atualiza_condutores.sh
        ;;

    "Stats")
        exec ./stats.sh
        ;;

    "Sair")
        break
        ;;
    *) echo "invalid option $REPLY";;
  esac
done
2
  • 1
    Use a while around your select. Also, quote your variables exec ./cria_condutor.sh "$nestudante" "$nome". Commented Oct 12, 2018 at 14:47
  • You can use read -p "Insira o número de estudante: " nestudante Commented Oct 12, 2018 at 22:09

1 Answer 1

1

You use exec to replace the current process with what you call. Just strip the exec to create a subprocess instead, wait for its termination, and then continue with your script:

read matricula
./cria_condutor.sh $nestudante $nome $turma $ntelemovel $email $tipo $marca $matricula
break;;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.