Created
January 4, 2016 20:41
-
-
Save fideloper/b465064629689af579f3 to your computer and use it in GitHub Desktop.
Execute a shell script
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
// Import fs (filesystem) | |
var chmodSync = require('fs').chmodSync; | |
// Import execFile, to run our bash script | |
var execFile = require('child_process').execFile; | |
chmodSync('./build.sh', 0755); | |
var execOptions = { | |
maxBuffer: 1024 * 1024 * 5 // Increase max buffer to 5mb | |
}; | |
execFile('./somethiung.sh', ['-b foo', '-r bar'] , execOptions, function(error, stdout, stderr) { | |
if(error) | |
{ | |
console.error('Error: '+error.message); | |
} | |
// Log success in some manner | |
console.log( 'exec complete', stdout, stderr, error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the PoC. I suppose an enhancement at line #12 would be:
Because the
stderr
is ramble, without any kind of [error] handling on it.