0
I am making a simple configuration file in Shell script with a TUI(Text User Interface) using Whiptail, I need to restrict the user input so that the program accepted as input only a range of integer numbers, I was able to make it work manually, but impossible to define large intervals. follows a passage...
That way it works perfectly, it’s just a "dumb" way to do and impractical to set large intervals Status2 is the output status is (0 to confirm and 1 to cancel) range is the value entered by the user
intervalo=$(whiptail --title "Entre com o valor em sugundos do intevalo de verificação do ruído ambiente" --inputbox "Entre com um inteiro de 0 a 9 (recomendado:1)" --fb 10 80 3>&1 1>&2 2>&3)
status2=$? #echo "O status2 foi $status2 e intervalo= $intervalo" #sleep 4
if (( $status2 == 0 && $intervalo == 1 || $status2 == 0 && $intervalo == 2 || $status2 == 0 && $intervalo == 3 || $status2 == 0 && $intervalo == 4 || $status2 == 0 && $intervalo == 5 || $status2 == 0 && $intervalo == 6 || $status2 == 0 && $intervalo == 7 || $status2 == 0 && $intervalo == 8 || $status2 == 0 && $intervalo == 9 )); then
echo "Intervalo = $intervalo"
else
echo "Configuração cancelada."
exit 0
fi
What is the simplest correct way to define the multiple conditions of this loop if
??
Something like: if (( $status2 == 0 && $intervalo > 0 && $intervalo < 10); then
...
So it does not work and does not restrict decimal numbers.