Created
October 20, 2013 02:36
-
-
Save JesseHerrick/7064232 to your computer and use it in GitHub Desktop.
Execute a shell command with Node.js.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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