title: PHP exec and OSASCRIPT?
body: <p>I have a little Apple script as follow:</p>
  
  <pre><code>beep
  delay 2
  tell application "Finder" to activate
  </code></pre>
  
  <p>It just makes a sound, wait 2 second and then bring the "Finder" window to the foreground.</p>
  
  <p>When I run it from the command line, it works fine.</p>
  
  <p>Then I want PHP to call that script using the exec() php function. </p>
  
  <pre><code>&lt;?
  $cmd = "/usr/bin/osascript \"myscript.scpt\"";
  exec($cmd);
  ?&gt;
  </code></pre>
  
  <p>It still works fine.</p>
  
  <p>But when I call that same PHP script from the browser, it doesn't work! The PHP starts, the Apple script starts as well since I can hear the beep sound but its last line is not executed.</p>
  
  <p>I thought that would be an environment variable thing so I made sure they were all the same way as in the terminal:</p>
  
  <pre><code>$cmd = "HOME='/Users/mikael' &amp;&amp; … &amp;&amp; /usr/bin/osascript \"myscript.scpt\"";
  </code></pre>
  
  <p>The variables are set properly (as check with env|sort) but still no luck with running my apple script inside a php script displayed in the browser and using the standard MacOS apache stuff.</p>
  
  <p>Any idea?</p>