I’ve just installed Bernhard Baehr’s SleepWatcher, a daemon (with a package installer) that will trigger other scripts stored as .sleep or .wakeup saved in your home folder. These must be unix executables. I’ve got an AppleScript that runs a bunch of others when I wake my machine up, and I’d like to start that automagically when I wake the machine, i.e., when the machine wakens without further action by me than tapping the space bar to wake the machine (I never shut it down).
Questions:
- What does the simplest executable that will start an AppleScript saved as a script, whose address I know, contain? (I’ve never written one - I always use do shell script for unix commands)
- Do I just write it as text (BBEdit, say) and save it as text without an extension? (Not familiar with unix editors)
- What is the appropriate chmod mode to make it executable by owner? (seems to be octal 0100 from the man page, but I’ve never used chmod)
Thanks to any of our UNIX gurus.
Hi Adam - I think I understand what you are asking for - and here’s a way to do it.
When writing a shell script - I always use the extension .sh, but you don’t have to, it’s just good practice. So - you could have a simple bash script like (I use bbedit) and save it with unix line breaks (important!)
#!/bin/bash
open /Users/username/Desktop/Untitled.app
Then - make an applescript and save it as an application, make sure you have Show Startup Screen UNchaecked, to the path you specify in the shell script - in this example the AS is on my desktop and called Untitled.app.
Then open Terminal and type chmod 755 /pathtoyourshellscript
that will set the perms of the shell script so that it is exeutable.
Now - when you run the shell script from terminal or your other methods - it will run that applescript.
Hope that helps
Chris
I’ll let you know when I try it, but thanks a ton for the really cogent answer.
Turns out that to run a compiled AppleScript all you need is a line like this:
/usr/bin/osascript /Users/shortName/Library/Scripts/DoSomeThing.scpt
saved as text and given appropriate permissions:
chmod 755 /path to the document/theDoc