5
I’m creating a script
simple learning where the user should:
- Enter number that will be saved in the NUM1 variable
- Enter a second number that will be saved in the NUM2 variable
- Choose from the menu if it wants to add, subtract, multiply or split these numbers.
After these procedures, it should appear in the terminal "The option chosen was: sum (as for example, if he had chosen subtraction, subtraction would appear there [without accent because it is the variable I want to appear]).
Code I created:
#!/bin/bash
clear
NUM1=$( gdialog --inputbox "Informe o número 1"
gdialog --title 'Aviso' )
NUM2=$( gdialog --inputbox "Informe o número 2"
gdialog --title 'Aviso')
escolha=$( gdialog \
--menu 'Escolha:' \
0 0 0 \
soma '+' \
subtracao '-' \
multiplicacao '*' \
divisao '/' )
echo "A opção escolhida foi: $escolha"
exit
Problem: When I run, I do all the procedures as a user until the choice in the menu, appears in the terminal what was chosen, however, is not what I asked to appear and soon below appears "The chosen option was:" and does not appear the variable in front.
I would like this variable to appear so I see that it is actually being saved in $choice, so I can find a way to use the switch case and finish my script.
NOTE: Use gdialog for visual mode.
No problem, rsr... It’s just that I wanted in visual mode, hence the gdialog help in this.
– Marcielli Oliveira
Got it, I don’t know this function yet.
– Roknauta
All right, thank you... ;)
– Marcielli Oliveira