AppleScript Shell

A few months ago, Cameron Hayne told me about his nifty AppleScript Shell (ash), which offers an interactive command-line interface to AppleScript, and lets you do some nifty tricks like “tracing” a script’s execution, printing the resulting value for each executed statement.

But I just discovered something about ash that’s truly magical. Think “Remote Script Editor”! I’m in a hotel when I realize I need to access some information from an Address Book entry back home. So I ssh into my home computer, and start slogging through the Address Book data folder. Ugh! If only I could easily ask for the scripted information I need. Of course, there’s osascript, which is where I started heading. But ash makes this process so much easier, because of its interactive and forgiving interface:

iBook> ./ash
Welcome to ash (AppleScript Shell) version 0.60
Type: -help for help, type -exit to exit
ash> tell application "Address Book"
tell application "Address Book"
ash tell> set myPerson to first person whose name is "John Doe"
tell application "Address Book"
set myPerson to first person whose name is "John Doe"
ash tell> value of phones of myPerson
tell application "Address Book"
set myPerson to first person whose name is "John Doe"
value of phones of myPerson
ash tell> end
tell application "Address Book"
set myPerson to first person whose name is "John Doe"
value of phones of myPerson
end tell
{"(415) 555-1384", "(415) 555-4424"}
ash>

See how ash takes one line at a time, and then when I end the “tell” block, it shows me the results of my query. Now I can call my friend even though I’m nowhere near my Mac.

Yeah, yeah, yeah. Or I could run VNC, or ya know, put phone numbers on my iPod. But this is just one example of a scenario where interactive scripting could be handy through a remote ssh connection.

AppleScript Shell, check it out!