var Q = require("q"); var childProcess = require("child_process"); function dumper(content){ console.log(JSON.stringify(content)); } //okay...this works...I had to cut out sh.on...does this seem alright? hope so //when I use sh.on("exit",...) for whatever reason it isn't working, do you have an idea of why? shouldn't it be childProcess.on() instead? no function execute(cmd){ var deferred = Q.defer(); var result = {}; var sh = childProcess.exec(cmd, function(error, stdout, stderr){ result.stdout = stdout; result.stderr = stderr; result.error = error; }); sh.on("close", function(){ deferred.resolve(result); }); return deferred.promise } execute("echo bitches").then(function(result){ dumper(result) }); //DO NOT USE sh.on("exit"... //so instead of exit, "close" event. exit will just says that child exited, and i gues sonly after emitting this event //childproicess start to push data to stdout callback. great