Skip to content

Instantly share code, notes, and snippets.

@thluiz
Created October 4, 2012 00:08
Show Gist options
  • Save thluiz/3830699 to your computer and use it in GitHub Desktop.
Save thluiz/3830699 to your computer and use it in GitHub Desktop.
Run shell commands via NodeJS
var exec = require('child_process').exec;
var child = exec("echo 'teste'",
function (error, stdout, stderr) {
if(stdout!==''){
console.log('---------stdout: ---------\n' + stdout);
}
if(stderr!==''){
console.log('---------stderr: ---------\n' + stderr);
}
if (error !== null) {
console.log('---------exec error: ---------\n[' + error+']');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment