Skip to content

Instantly share code, notes, and snippets.

@JesseHerrick
Created October 20, 2013 02:36
Show Gist options
  • Save JesseHerrick/7064232 to your computer and use it in GitHub Desktop.
Save JesseHerrick/7064232 to your computer and use it in GitHub Desktop.
Execute a shell command with Node.js.
// Code:
var exec = require('child_process').exec;
var execute = function(command, callback){
exec(command, function(error, stdout, stderr){ callback(stdout); });
};
// Example:
execute("git --version", function(version){
console.log(version);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment