I have the following Applescript which runs fine from the applescript editor in both Snow Leopard and Lion. I can also run it using osascript via terminal on Snow Leopard but not on Lion. The code is as follows
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
The script opens and executes a Mathematica script. It is successful for the scenarios above but when I try to run it using osascript in Lion I get a Mathematica window which states that "the requested file could not be found or accessed".
Help greatly appreciated.