0

My goal is to be able to submit a search query from a web form and have an AppleScript execute the search in DEVONagent. The AppleScript works fine in terminal but I get an error when having PHP do a shell_exec().

<?php
$theQuery = $_GET["Query"];
$cmd = "theSearch=\"$theQuery\" osascript -e \"set theSearch to system attribute " . "\\" . "\"theSearch" . "\\" . "\"\" -e \"tell application " . "\\" . "\"DEVONagent" . "\\" . "\"\" -e \"search theSearch using set " . "\\" . "\"Web (Deep Link)" . "\\" . "\"\" -e \"end tell\" 2>&1";
echo "<pre>$cmd</pre><BR><BR>";
$theResponse = shell_exec ( $cmd );
echo "Your search for \"$theQuery\" has started and the results will be emailed to you once complete.";
echo "<pre>$theResponse</pre>";
?>

I end up with the following error from the $theResponse echo:

83:92: syntax error: Expected end of line but found identifier. (-2741)

I'm thinking maybe a permissions thing but I just cannot figure it out.

Justin
  • 43
  • 5
  • If you `sudo` that exact same `shell_exec` from an interactive prompt in the shell do you get the same error message? – Phillip Berger May 30 '13 at 23:12
  • I did try adding 'echo SECRET | sudo -S' before the command if that is what you mean, but all I got was an error that the password was incorrect three times. The strange thing is that again when I run it in Terminal everything is just fine. – Justin May 31 '13 at 03:40

0 Answers0