2013-01-08 55 views
2

我有以下Applescript可以在Snow Leopard和Lion的applescript編輯器中正常運行。我也可以在Snow Leopard上通過終端使用osascript而不是在Lion上運行它。代碼如下爲什麼我的Applescript在Snow Leopard上使用osascript在終端上運行,但在Lion上卻不能運行?

tell application "System Events" 
try 
    get process "Mathematica" 
on error -- Not running, launch and run 
    launch application "Mathematica" 
    -- May need to wait until application finishes launching 
    repeat while "Mathematica" is not in name of processes 
     delay 0.5 
    end repeat 
end try 
end tell 
tell application "Mathematica" 
activate 
do script "notebook0=NotebookEvaluate[\"/Users/me/file.nb\"]; 
      Clear[notebook0];NotebookClose[EvaluationNotebook[]]" 
end tell 

腳本打開並執行Mathematica腳本。它對上述場景很成功,但是當我嘗試在Lion中使用osascript運行它時,我得到一個Mathematica窗口,其中聲明「請求的文件無法找到或訪問」。

非常感謝。

回答

0

當您啓動應用程序「Mathematica」時,我建議您爲應用程序提供完整路徑。

相關問題