My python scripts returns some text on console while execution is going on, but when executed via child_process.spawn in node.js, stdout.on
doesn't give me real-time output on console, instead stdout.on
is executed when spawn process is about to end.
var spawn = require("child_process").spawn
var command = ['esx_trace.py', '-w', '28796829', '-v', '8496', '-i', '10.1.1.38', '-u', 'root', '-p', 'whatever', '-t', '5'];
var child = spawn('python', command);
child.stdout.on("data", function (data) {
console.log("spawnSTDOUT:", data.toString())
})
child.stderr.on("data", function (data) {
console.log("spawnSTDERR:", data.toString())
})
child.on("exit", function (code) {
console.log("spawnEXIT:", code.toString())
})