我正在使用对话框编写脚本来提示用户问题等。其中一个步骤是运行命令以生成一些信息。我有一个 if 语句,以防它失败,我想做的是,以防它无法让用户重新运行它。有点迷失了如何去做。
脚本本身
#!/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
所以基本上,它说“#loopback to $UID_GREP”我想要它,如果选择是循环回UID_GREP对话框屏幕。
谢谢你。