[Project_owners] getting output from external process

Stan James sjames at uni-osnabrueck.de
Wed Mar 16 11:56:49 EST 2005

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);

Can I grab stdout from JavaScript? Is there another way to redirect 
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! :)

More information about the Project_owners mailing list