I can run a bash command in node.js like so:
var sys = require(\'sys\')
var exec = require(\'child_process\').exec;
function puts(error, stdout, stderr) { s
Those 2 commands are running in separate shells.
To get the code, you should be able to check err.code in your callback.
If that doesn't work, you need to add an exit event handler
e.g.
dir = exec("ls -la", function(err, stdout, stderr) {
if (err) {
// should have err.code here?
}
console.log(stdout);
});
dir.on('exit', function (code) {
// exit code is code
});