AppleScript ASObjC Runner未显示Shell脚本的进度

时间:2014-12-17 15:52:37

标签: shell terminal applescript

好的,所以我使用ASObjC Runner制作了进度条,但它没有显示shell脚本的进度,也没有在shell脚本完成后隐藏进度条。谁知道为什么?

现在是代码:

display alert "You may have to restart your computer after using this tool!" buttons {"Ok"} default button 1

set question to display dialog "RMR (Remove My Redirect)

Are you unable to go to a website at home because of that annoying St. Bernard Redirect?

If the answer is Yes, then RMR is your solution! Simply Choose Remove to remove it, and Replace to put it back." buttons {"Remove", "Replace", "Erase Evidence"} default button 3
set answer to button returned of question

if answer is equal to "Remove" then do shell script "mv /Library/LaunchDaemons/com.stbernard.rfcd.plist ~/"

if answer is equal to "Replace" then do shell script "mv ~/com.stbernard.rfcd.plist /Library/LaunchDaemons/"

if answer is equal to "Erase Evidence" then set question to display dialog "Are you sure? RMR will be deleted forever." buttons {"Yes", "No"} default button 2
set answer to button returned of question

if answer is equal to "No" then do shell script "echo"

if answer is equal to "Yes" then ¬
    tell application "ASObjC Runner"
        reset progress
        set properties of progress window to {button title:"Cancel", button visible:true, message:"Removing...", detail:"Please be patient", indeterminate:false, max value:100, current value:0}
        activate
        show progress
    end tell
repeat with i from 1 to 100
    do shell script "srm -rf ~/Downloads/RMR.app; history -c; killall Terminal"
    tell application "ASObjC Runner"
        activate
        set properties of progress window to {detail:"Progress: " & i, current value:i}
        if button was pressed of progress window then
            exit repeat
        end if
    end tell
end repeat
tell application "ASObjC Runner" to hide progress

提前致谢!

此外,这里还有一个指向该应用的链接,以备不时之需:RMR

1 个答案:

答案 0 :(得分:0)

两个想法:1。确定shell脚本是同步/异步的问题。既然你分发了工作负荷,不知道pb对它做了什么。 2.从剥离脚本的内容开始,只留下流程,对话框和if子句。用延迟语句替换所有的东西(做shell脚本等),以便首先测试你的pb。

但是,你正在寻找|回答|被设置为"是",但它永远不会被设置为"是"在你的脚本中。这不是对话框中的选项。???您需要逐步减少和测试脚本的各个部分。

我也会避免使用该助手应用,这可能是您问题的一部分。您可以在没有它的情况下执行进度条,正如您在上一个问题的答案中所看到的那样:stackoverflow.com/questions/27517042/…

- jweaks