1
votes

Ok, so I have the progress bar made, using ASObjC Runner, but it doesn't show the progress of the shell script, and also doesn't hide the progress bar after the shell script completes. Anyone know why?

Here is the code now:

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

Thanks in advance!

Also, here is a link to the app in case you need it: RMR

1
Two thoughts: 1. There for sure are issues with do shell script being synchronous/asynchronous. Since you hand out the work load, not sure what the pb does with that. 2. Start off by stripping out the guts of your script, leaving just the flow, the dialogs and the if clauses. Replace all the stuff (do shell scripts, etc) with delay statements, in order to first test your pb. - jweaks
However, you're looking for |answer| being set to "Yes", but it will never be set to "Yes" in your script. That's not an option in the dialog box.??? You need to reduce and test parts of your script bit by bit. - jweaks
I would also avoid using that helper app, which may be part of your problem. You can do a progress bar without it, as you can see in the answer to your previous question: stackoverflow.com/questions/27517042/… - jweaks
Thanks @jweaks! I got it to work. - SchoolDev

1 Answers

0
votes

Two thoughts: 1. There for sure are issues with do shell script being synchronous/asynchronous. Since you hand out the work load, not sure what the pb does with that. 2. Start off by stripping out the guts of your script, leaving just the flow, the dialogs and the if clauses. Replace all the stuff (do shell scripts, etc) with delay statements, in order to first test your pb.

However, you're looking for |answer| being set to "Yes", but it will never be set to "Yes" in your script. That's not an option in the dialog box.??? You need to reduce and test parts of your script bit by bit.

I would also avoid using that helper app, which may be part of your problem. You can do a progress bar without it, as you can see in the answer to your previous question: stackoverflow.com/questions/27517042/…

– jweaks