bash script create a loopback on failure (using dialog)
I am writing a script using dialog to prompt user with questions, etc. One
of steps is running a command to generate some info. I have a if statement
for it in case it fails, what i want to do is, in case it fails to give a
user ability to re-run it. A bit lost on how to do it.
Script itself
#!/bin/bash
#Generating UID
UID_GREP=${UID_GREP=dialog}
$UID_GREP --title "Appliance Imaging Script" --clear \
--yesno "Begin Generate UID for Appliance:" 10 30
case $? in
0)
#uid generate script
/usr/share//bin/create >/tmp/appliance_run.log 2>&1
;;
1)
clear
echo "exiting"
exit;;
255)
clear
echo "ESC Pressed... Exiting"
exit;;
esac
#if Generation of UID fails
if [ $? != 0 ] ; then
UID_FAIL=${UID_FAIL=dialog}
$UID_FAIL --title "UID Genenration failed" --clear \
--yesno "UID failed to genenerate, would you like to try again"
10 30
case $? in
0)
#loopback to $UID_GREP
;;
1)
clear
echo "exiting"
exit;;
255)
clear
echo "ESC Pressed... Exiting"
exit;;
esac
fi
So basically, where it's says "#loopback to $UID_GREP" i want it, if yes
is selected to loop back to the UID_GREP dialog screen.
Thank you.
No comments:
Post a Comment