O'Reilly logo

Mac OS X Hacks by Rael Dornfest, Kevin Hemenway

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

AppleScript CGI with ACGI Dispatcher

It’d be a shame if you couldn’t use AppleScript to automate web-serving tasks with Apache. ‘Tis no shame; you can.

When Apple based OS X on a BSD kernel, they sought a way to combine the power of GUI scripting with the power of shell languages like Perl, bash, Python, and more. The result was osascript , a simple shell utility that could run AppleScript from the command line.

That was fine and dandy for interactive or timed usage, but it didn’t immediately lend itself to using AppleScript as a CGI through the Apache web server. ACGI Dispatcher from James Sentman, on the other hand, gives that ability quickly, simply, and cheaply.

ACGI Dispatcher costs anywhere from $15 to $90, depending on your needs, and a 30-day trial download is available for testing. Installation is simple: extract, drag the dispatcher to your /Library/WebServer/CGI-Executables directory, and double-click to finish the installation. You’ll be asked for your administrator password so that the following lines can be added to your /etc/httpd/httpd.conf file:

#BEGIN acgi dispatcher
Include /Library/WebServer/CGI-Executables/dispatcher.app/Contents/acgi.conf
#END acgi dispatcher

After those lines have been added by the dispatcher program, stop and restart Apache via your Sharing system preference (alternatively, use sudo apachectl restart from the shell). Once the web server has restarted, and with the dispatcher running in the background, you’ll be all set to serve AppleScript-based ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required