bridging php and applescript

February 25th, 2006


While playing around with building a web interface for my deeply closeted media server, I uncovered a nifty how-to that lets you send osascript commands — essentially, AppleScript commands executed on the command line — via php. This allowed me to create a web page which passes AppleScript commands to iTunes which then streams music to my stereo: pretty cool.

The downside? Welp, long story short, to be able to fire off AppleScript commands via php exec statements, you’ve got to run Apache as “you”; normally, Apache runs as an unprivileged user called “www”. Setting up Apache to run as “you” is pretty unsecure, even by my horribly loose definition of secure; there’s got to be a better way to integrate AppleScript and the web…


2 Responses to “bridging php and applescript”

  1. Brendan says:

    I want to suggest something about using php to write the commands to a file, then setting up a cronjob to run them as you every five minutes or whatever, but it’s all very vague in my head.

  2. […] Configure Apache to run as your own user, instead of the WWW user — a serious security risk. Only do this on an internal network! The WWW user won’t have adequate permissions to do what we need to. […]