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 ...

Get Mac OS X Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.