[Project_owners] getting output from external process
patrick.brunschwig at gmx.net
Wed Mar 16 12:52:31 EST 2005
Stan James wrote:
> Hi all,
> Is there a simple way to get the output of an external process? When I
> run (for example) SQLite using nsIProcess, the results scroll by in the
> console window, but I can't figure out how to grab them in my extension
> code. I also tried doing a stdout redirect (and read the output file
> after the process terminates), but output still goes to the console and
> no output file is created.
> Here's the code: (Mostly taken from
> // create an nsILocalFile for the executable
> var file = Components.classes["@mozilla.org/file/local;1"]
> // create an nsIProcess
> var process = Components.classes["@mozilla.org/process/util;1"]
> // Run the process.
> // If first param is true, calling process will be blocked until
> // called process terminates.
> // Second and third params are used to pass command-line arguments
> // to the process.
> var args = ["C:\\temp\\test", "select * from tblReports;",
> //var args = ["C:\\temp\\test", "select * from tblReports;",
> process.run(true, args, args.length);
> output from the process?
> Thanks for any tips!
I don't think that there is a standard way in Mozilla. However, you can
use the ipc (pipe) library that was orignially developped for Protozilla
and is now used in Enigmail.
More information about the Project_owners