How to execute an external program from within Node.js?

Michael Bylstra picture Michael Bylstra · Apr 25, 2011 · Viewed 125.9k times · Source

Is it possible to execute an external program from within node.js? Is there an equivalent to Python's os.system() or any library that adds this functionality?

Answer

Mark Kahn picture Mark Kahn · Apr 25, 2011
var exec = require('child_process').exec;
exec('pwd', function callback(error, stdout, stderr){
    // result
});