Skip to content

Instantly share code, notes, and snippets.

@afucher
Last active August 29, 2015 14:28
Show Gist options
  • Save afucher/14da6a7816eaf91a8ded to your computer and use it in GitHub Desktop.
Save afucher/14da6a7816eaf91a8ded to your computer and use it in GitHub Desktop.
Echo from bat file
(function() {
var childProcess = require("child_process");
var oldSpawn = childProcess.spawn;
function mySpawn() {
console.log('spawn called');
console.log(arguments);
var result = oldSpawn.apply(this, arguments);
return result;
}
childProcess.spawn = mySpawn;
})();
var spawn = require('child_process').spawn;
var ls = spawn(__dirname + '\\teste.bat',[],{stdio:'inherit'});
/*
ls.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
ls.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
*/
ls.on('exit', function (code) {
console.log('child process exited with code ' + code);
});
ls.on('uncaughtException', function(err) {
console.log('Caught exception: ' + err);
});
@echo off
echo aparece alguma coisa!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment