Option 1 (BridgeTalk)
I had to do something like this to run an external PNG processor from both Photoshop and Illustrator. Neither of those applications have the ability to execute external programs from ExtendScript. (See Option 2.) Adobe Bridge's app object has a system method that executes a command in the system shell. Using a BridgeTalk object, you can call that method remotely from Illustrator. You'll only get the exit code in return, though. So you'll need to redirect your program's output to a file and then read that file in your script.
Here's an example of using BridgeTalk and Adobe Bridge to run an external program:
var bt = new BridgeTalk();
bt.target = 'bridge';
bt.body = 'app.system("ping -c 1 google.com")';
bt.onResult = function (result) {
$.writeln(result.body);
};
bt.send();
Pros
- Asynchronous
- Can easily retrieve the exit code
- Can use shell syntax and pass arguments to the program directly
Cons
- Adobe Bridge must be installed
- Adobe Bridge must be running (although BridgeTalk will launch it for you, if needed)
Option 2 (File.prototype.execute)
I discovered this later and can't believe I missed it. The File class has an execute instance method that opens or executes the file. It might work for your purposes, although I haven't tried it myself.
Pros
- Asynchronous
- Built into each ExtendScript environment (no inter-process communication)
Cons
- Can't retrieve the exit code
- Can't use shell syntax or pass arguments to the program directly
Socketclass. - Josh Voigts