Getting Apache PHP script to do something in GUI?

throatmonster

Registered
I'm trying to use a Mac Mini as a Digital Signage display driver, and also as a controller for the display. I'm using Python and a Keyspan USB Serial adapter driven by PHP scripts to control the display, and all that is working really well.

What I can't seem to figure out is how to get the GUI to open a PowerPoint Slideshow in the GUI via PHP. I'm running Apache as the logged in GUI user, I can do an "open powerpoint.pps" in the shell and that works, but the same command in PHP ( exec("open powerpoint.pps") ) does not work.

Maybe I can get automator to watch a folder or file, and when the file timestamp changes, provoke the action? Then a new file upload, or an exec command that copies and rewrites the existing file should do it.

But, does anyone know a better way than that, maybe how to get a PHP script to directly provoke some action in the logged in GUI user?

Thanks,
 
This actually should be possible, provided
1. You wrap the open command in a shell script
2. httpd has execute permission for the shell script
3. httpd has read permission for the document, including the entire path to the document

For instance, if you write a shell script at /tmp/open.sh that looks like this:

Code:
#!/bin/sh
/usr/bin/open /tmp/my-presentation.pps

And set permissions to 777 (or chown it to www, etc.), and write a PHP script that looks like this:

Code:
<?php
exec("/tmp/open.sh");
?>

You should be in business, provided the PHP script is in htdocs somewhere. If this script chain fails somewhere, it will be due to permissions / access issues, not to an inherent limitation in the scheme.
 
Back
Top