我的目标是能够从 Web 表单提交搜索查询并让 AppleScript 在 DEVONagent 中执行搜索。AppleScript 在终端中运行良好,但在让 PHP 执行 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>";
?>
我最终从 $theResponse 回显中得到以下错误:
83:92: syntax error: Expected end of line but found identifier. (-2741)
我在想也许是权限问题,但我就是想不通。