我有一个在 Mac OS X(X.5 到 X.8)机器上使用的 bash 脚本。在它是一个对话框情况,要求通过按“确定”继续脚本或通过按“打盹”让脚本打盹。那部分正在工作。
但是,我正在测试脚本并且无法立即按下任一按钮,并且在一两分钟后(我没有计时),脚本继续执行其余过程,让对话框留在屏幕上。
我的印象是脚本必须等待用户输入?
部分有问题的脚本:
osascript -e '告诉应用程序“Finder”激活'
返回=osascript -e 'tell app "Finder" to display dialog "Text goes here. Please select OK or Snooze" buttons {"OK", "Snooze"} default button 1 with title "Text Here" with icon caution'
    ############  BEGIN LOOP HERE  ##############
while [ "$return" == "按钮返回:贪睡"]
        do
        Runs every 4 hours
        sleep 14400
        osascript -e 'tell app "Finder" to activate'
        return=`osascript -e 'tell app "Finder" to display dialog "Text goes here. Please select OK or Snooze" buttons {"OK", "Snooze"} default button 1 with title "Text Here" with icon 2'`
完毕
###### 在这里结束循环    if [ "$return" == "button returned:OK" ]
        then
                    run the installer script here
            fi