Created
June 20, 2018 20:58
-
-
Save excenter/4362c01871f22334af2e296f64a90812 to your computer and use it in GitHub Desktop.
a javascript function that takes a string and runs it as bash, returning the output to the std pipes.
This file contains 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
function bashRun(command){ | |
var exec = require('child_process').exec; | |
console.log(command); | |
var child = exec(command); | |
child.stdout.on('data', function(data) { | |
console.log('stdout: ' + data); | |
}); | |
child.stderr.on('data', function(data) { | |
console.log('stderr: ' + data); | |
}); | |
child.on('close', function(code) { | |
console.log('closing code: ' + code); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment