I’m making a simple program using AppleScript to run my crontabs, similar to MacJanitor, because I’ve found myself shutting down my computer a lot recently.
Here’s what I have so far, but it’s saying “File “./Daily.sh” does not exist”, but it does and I can run that exact command in the Terminal. Here’s the code:
display dialog "Run Daily, Weekly, or Monthly Crons?" buttons {"Daily", "Weekly", "Monthly"} default button "Daily"
set Cleen to button returned of the result
if Cleen = "Daily" then
do shell script "./Daily.sh" with administratorpriveleges
end if
if Cleen = "Weekly" then
do shell script "./Weekly.sh" with administratorpriveleges
end if
if Cleen = "Monthly" then
do shell script "./Monthly.sh" with administratorpriveleges
end if
Any ideas on how to get this to work?
edit: The shell script I’m referencing is “sudo sh /etc/Daily” same for monthly and weekly.
I used pico to make that into “Daily.sh”, then used “chmod +x Daily.sh” to make the file executable.
Awesome, thanks a lot. It works, but it’s really confusing in the fact that you can’t see the progress. Is there a way in AppleScript to make a simple progress bar that coincides with the the amount of time the script takes to finish?
AppleScript won’t know how much time is left. You could have a simple progress bar (like this one) that just spins (a.k.a. indeterminate). Alternatively, you could modify your shell scripts to use iHook (may not be an option if you want to use this app on other computers).
Edit: About that progress bar. you could fake it by guessing how much time the script will take. In OS X v10.4, this is how the “Starting Mac OS X.” progress window (seen during the boot process) works (see Daring Fireball).