I have the following function:
function ping {
nome=$(dialog --title "inform o endereço que deseja PINGAR" --inputbox "IP ou URL - \
Lembrando que será disparado 10 pings para o endereço informado." 10 45 --stdout)
status=$?
if [[ $status -eq 0 ]]; then
ping -c 10 $nome
rc=$?
if [[ $rc -eq 0 ]]; then
echo "#####################################"
echo "## Endereço: $nome | Status: UP"
echo "#####################################"
else
echo "#####################################"
echo "## Endereço: $nome | Status: DOWN"
echo "#####################################"
fi; else; echo "Você optou por cancelar a operação."; fi; } valor='ping'; echo "RESULTADO FOI: "$valor
But when I run the script ( ./meuscript.sh
), I have no return, only if I select cancel in the dialog.
If I run the script without the function, the command executes correctly, displaying the correct 'echos'.
What am I doing wrong? Thank you for your attention!