开发者

Execute Applescript in Sites Folder

I sear开发者_StackOverflow中文版ch every where on the web to the information below : How to execute a applescript in the "Sites" folder. Let me explain : I have made a litthe script (PHP) which execute an applescript which open a file applescript :

tell application "Finder"
open file "Macintosh HD:Utilisateurs:my-user:FOO.pdf"
end tell

my php script :

exec("osascript ShutDown.scpt");

When i execute it from localhost, it's working. But when i'm accessing it with Sites folder http://my-user.home/myPhpScript.php it's not working. You can find the error in apache below :

my-user.home osascript[1323] <Error>: kCGErrorFailure: Set a breakpoint @  
CGErrorBreakpoint() to catch errors as they are logged.
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer,     
_CGSDefaultConnection() is NULL.

Do you know any solution to make it work ?

Thanks you very much


The www user cannot use osascript. You'll have to edit the apache config file to run as your user. This works but isn't very secure.


If running the script directly from the web page won't work because of permissions, try working around it. Have PHP create a file in a folder that is generally empty within the Sites folder. Then use either folder events or an idle handler script to check that folder for the file and if one exists execute the functionality you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜