[Project_owners] getting output from external process
richwklein at mchsi.com
Wed Mar 16 18:42:44 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!
> ps - Yes, I know I should just integrate SQLite via XPCOM. Has anyone
> done this before? Seems like it'd be useful, but a bit daunting for my
> first XPCOM project! :)
If you are using a trunk build sqlite is already built into xpcom.
Check out: http://lxr.mozilla.org/mozilla/find?string=mozistorage for
the interfaces to it.
More information about the Project_owners