Ash: An AppleScript Shell
Looking for an easier alternative to osascript that still runs in the command line? Check out AppleScript Shell from Hayne of Tintagel. It’s a Perl-powered script that lets you interactively execute AppleScript commands (including multi-line tell commands) as well as create interpretable scripts (via #!/usr/bin/env ash). There are a number of useful flags built in that can be used to execute commands from a specified file, echo values during execution, to display the current AppleScript, to repeat the most recent script, to call Unix commands, and so forth. e.g.
tell application “Finder”
set theSelection to selection
set n to number of items in theSelection
-echo “number of items selected: ” & n
repeat with i from 1 to n
-echo “item ” & i & “ is ” & (item i of theSelection as alias)
end repeat
end tell
The script downloaded easily–although you do have to gunzip it and chmod it to make it executable. I pasted in one of my standard rename scriptlets and it ran perfectly, updating a playlist in iTunes. There were some strange echos during the execution trace, i.e. it listed the whole script up to the current line for every step along the way, but I’m guessing this could be turned off by one of the built-in flags or by editing the source itself, which is quite short.
