0

I was trying some things with osascript when I had this problem.

Here is my test :

/usr/bin/osascript <<-EOF

    tell application "System Events"
        activate
        display dialog "Hello world"
    end tell

EOF

Here is my PHP file.

<?php
$output = shell_exec("./test");
echo "<pre>$output</pre>";
?>

Do you have any ideas why this does not work? (It's not really important but I was just curious about it)

j0k
  • 22,600
  • 28
  • 79
  • 90
Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134

1 Answers1

0

I suspect the osascript executable requires environment variables to be set up to work correctly, which is why this works fine from the console. See this answer to show you how to set these up from PHP.

In my case it was the HOME variable, but it could be something else. Keep adding them until it works!

Community
  • 1
  • 1
halfer
  • 19,824
  • 17
  • 99
  • 186
  • Well. It seems like error 10810 is because I asked the system to open the popup but the system doesn't want unless you do it from an app. I can call scripts directely with `system()` or `shell_exec()` that do not require GUI elements – Matthieu Riegler Jan 10 '13 at 23:08
  • Righto. Yes, I wouldn't expect anything that pops up dialogue boxes to work through PHP in a web process. – halfer Jan 11 '13 at 12:33