I'm trying to execute a program (binary), that is printing values regularly on the stdout.
with exec, it works fine, but with spawn, results only comes after a while, why ? what can I do about that ?
const opcv=spawn("myprog",["-L","2","-o","pairs","-r"], { shell:false, stdio:"pipe" })
opcv.stdout.on('data', (data) => {
node.log("opcdata stdout=" + data);
});
opcv.stderr.on('data', (data) => {
node.log("opcdata stderr=" + data);
});
I tried whith the option {stdio:"inherit"}, in that case I see the data directly, but I'm not able to work with ".stdout.on(" anymore :
TypeError: Cannot read property 'on' of null
EDIT It seems to be linked with the program I'm trying to run, but unfortunately its not possible to disable stdout buffering in the program, is it possible to execute it with another shell than cmd , or are they other tricks ?