Как передать аргументы из php exec в applecript

Я пытаюсь передать аргументы из моего php-скрипта в appleScript следующим образом;

function runAppleScript(){
exec("osascript processMail.scpt testing testing1");
}

и получите первый аргумент в appleScript, как это;

on run argv
set trimmedQuery to first item of argv

tell application "Fake"activate
open "Macintosh HD:Users:mini:Documents:fake workflows:login.fakeworkflow"delay 1
run workflow with variables {inputAddress:trimmedQuery}
wait until done
quit

end tell
end run

Но яблочный скрипт не работает. Если я уберу команду argv и установлю первый элемент, скрипт будет работать правильно. Я не уверен, что я делаю неправильно!

1

Решение

Вот что-то вроде того, что я использую для вызова файла AppleScript с аргументами из скрипта PHP:

PHP:

somefile.php:
#!/bin/php
<?php
$arg1 = $fname;
$arg2 = $path;
$cmd = "osascript example.applescript \"$arg1\" \"$arg2\"";
$returnval = exec($cmd);

AppleScript:

example.applescript:
on run argv
set fileNameArg to (item 1 of argv)
set pathArg to (item 2 of argv)
-- examples:
display dialog (item 1 of argv)
display dialog (pathArg)
if pathArg is in {{}, {""}, ""} then
on error
set filePath to (choose file name with prompt "Where would you like to save the file?" default name fileNameArg default location pathArg) as string
end try
end if
POSIX path of filePath
end run
1

Другие решения

Других решений пока нет …