Skip to content

Instantly share code, notes, and snippets.

@erickedji
Created March 3, 2009 07:09
Show Gist options
  • Save erickedji/73219 to your computer and use it in GitHub Desktop.
Save erickedji/73219 to your computer and use it in GitHub Desktop.
function executeShellCommand (program) {
//use arguments.shift to implement a complete shell bridge
var executable = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
executable.followLinks = true;
executable.initWithPath(program);
if (executable.exists()) {
try {
var process = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
process.init(executable);
var args = new Array();
Application.console.log("Executable : " + executable);
Application.console.log("args : " + args);
ret = process.run(false, args, args.length);
Application.console.log("ret code : " + ret);
} catch (e) {
Application.console.log("Error running command : " + e);
displayMessage("Error running command : " + e);
return null;
}
}
}
function cmd_testExec() { executeShellCommand('/media/data/personnal_works/soft/bin/test'); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment