How do you call an AppleScript process from an AIR native process?
Background:
I’ve created a script.scpt file and placed it in the root src directory of project.
I’m getting this error with what I have:
Error: Error #3219: The NativeProcess could not be started. 'launch path not accessible'
What I have:
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var file:File = File.applicationDirectory.resolvePath("MyScript.scpt");
var processArgs:Vector.<String>;
nativeProcessStartupInfo.executable = file;
nativeProcessStartupInfo.workingDirectory = File.applicationDirectory;
processArgs = new Vector.<String>();
processArgs[0] = "foo";
nativeProcessStartupInfo.arguments = processArgs;
process = new NativeProcess();
process.start(nativeProcessStartupInfo);
Solved
For it to work I needed the absolute path to “osascript” which is the command that runs scripts. In this case that command can be found in (along with a ton of other goodies)
Macintosh HardDrive > usr > bin > osascript
Note: The “usr” directory is hidden. The path is “/usr/bin/osascript”
var file:File = File.applicationDirectory.resolvePath("/usr/bin/osascript");
After that I passed the script file name as an argument. It also needs the working directory to be set to the directory of the script otherwise you get:
ERROR - osascript: script.scpt: No such file or directory
Answer added to the original post.