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
When i run the script (./meuscript.sh
), I have no return, only if i select cancel the dialog.
If I run the script without the function, the command is executed correctly