PHP / AppleScript

I know this may not be the best place to post this sensing as it’s primarily an AppleScript community, but I’ve tried posting in a PHP community I frequent and didn’t have any luck.

I’m creating a vanity website hosted on my home computer, and one of the features I’m wanting to implement is having my current AIM status displayed. I’ve made an AppleScript that writes my iChat status to a text file. The only problem is, to update the text file, the script has to be run. After a good night’s sleep, I realized I should just try and have PHP tell the server to run the script when the page is loaded. (I could run a cron every 5 minutes, but that seems impractical for a page that will be viewed once every 3 or 4 hours.)

I’m not very command-line savvy, and I’ve never run a program on a server from a PHP script. I have a feeling there’s a simple solution to this.

if(!exec('/Library/Apache2/htdocs/functions/')) { 
    echo('<br />The program wouldn't execute:'); 

I know I have the path right because if I type that exact same thing in the terminal, the script runs. I don’t think it’s permissions because they’re set to 777.

Is there anyone here who might be able to help?

This has been covered several times (try searching for PHP). In particular, take a look at this thread:



why don’t you wrap your script in an idle-Handler, save it as a stay open application and let it run in the backround.

It may then update your text file scheduled.

on idle
  -- your script here

  return 180 -- number of seconds (3 minutes here)
end idle

Maybe its useful and you don’t need php.


Thanks for the help guys! It’s a shame exec won’t work under MacOS X, but I think the idle handler or a cron will work.