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)