Repository URL to install this package:
|
Version:
0.5.1 ▾
|
| .. |
| example |
| test |
| lib |
| node_modules |
| README.md |
| .travis.yml |
| LICENSE |
| package.json |
| .npmignore |
| .jshintrc |
Execute shell command forwarding all stdio streams.
// JavaScript
execSh("echo hello exec-sh && bash", { cwd: "/home" }, function(err){
if (err) {
console.log("Exit code: ", err.code);
}
});
// Terminal output: interactive bash session
hello exec-sh
bash-3.2$ pwd
/home
bash-3.2$ exit 99
exit
Exit code: 99
exec-sh is a wrapper for child_process.spawn with improvements:
cmd /C COMMANDsh -c COMMANDexecSh("bash")execsh("echo -n Say: && read i && echo Said:$i")execSh("pwd", console.log)npm install exec-sh
var execSh = require("../");
// run interactive bash shell
execSh("echo lorem && bash", { cwd: "/home" }, function(err){
if (err) {
console.log("Exit code: ", err.code);
return;
}
// collect streams output
var child = execSh(["bash -c id", "echo lorem >&2"], true,
function(err, stdout, stderr){
console.log("error: ", err);
console.log("stdout: ", stdout);
console.log("stderr: ", stderr);
});
});
npm test
The MIT License (MIT)