2015-06-16 135 views
1

我有以下Bash腳本。將AppleScript添加到Bash腳本中

!#/bin/bash 

fscanx --pdf /scandata/Trust_Report 

if [ "$?" = "0" ]; then 

我想運行下面的AppleScript

tell application "FileMaker Pro Advanced" 
    activate 
    show window "Trust Reports" 
    do script "Scan Trust Report" 
end tell 



else 


    say 「It did not scan」 



fi 

什麼是正確的語法來調用這個AppleScript的?

謝謝

+1

有噸的鏈接,如果你搜索「從bash的運行AppleScript」。這是[許多中的一個](http://apple.stackexchange.com/questions/103621/run-applescript-from-bash-script)。 – chrisaycock

+0

[這是在askdifferent.stackexchange上回答](http://apple.stackexchange.com/questions/103621/run-applescript-from-bash-script) – davidcondrey

回答

5

使用osascript命令。您可以通過腳本使用-e標誌,像這樣的參數(注意這是沒有必要分成多行這個,我只是做到這一點使它更具可讀性):

osascript \ 
    -e 'tell application "FileMaker Pro Advanced"' \ 
     -e 'activate' \ 
     -e 'show window "Trust Reports"' \ 
     -e 'do script "Scan Trust Report"' \ 
    -e 'end tell' 

或者把它作爲一個這裏是這樣的文件:

osascript <<'EOF' 
tell application "FileMaker Pro Advanced" 
    activate 
    show window "Trust Reports" 
    do script "Scan Trust Report" 
end tell 
EOF 

順便說一句,你不需要測試$?在一個單獨的命令,你可以包括你要檢查的直接成功在if語句命令:

if fscanx --pdf /scandata/Trust_Report; then 
    osascript ... 
else 
    say 「It did not scan」 
fi 
+0

55:61:語法錯誤:預計行結束等但找到了課程名稱。 (-2741) – JFWX5