No live data with spawn
- Node.js Version:
- OS:
- Scope (install, code, runtime, meta, other?):
- Module (and version) (if relevant):
Version: 6.11.2 Platform: Win 64
Hi there, I'm using child_process with spawn. The command that I used is:
var ls = require('child_process').spawn('cmd.exe', ['/c', COMMAND WITH FULL PATH);
It executes just fine, it returns the data after the process is finished. However, I'm looking to get data streamed live back to the parent process. I'm using stdout, stderr and stdin but none of them streams the data live.
How can I get the data live using spawn (or any other child_process function)?
// I am an example of JS code
// please remove me too
-->
It executes just fine, it returns the data after the process is finished. However, I'm looking to get data streamed live back to the parent process. I'm using stdout, stderr and stdin but none of them streams the data live.
Can you explain how you got to that conclusion?
Hi and thank you for your reply.
Which conclusion would that be? That it executes fine or that the data is not streamed live?
That the data arrives, but that it doesn’t arrive “live”? Like, how do you know it’s not just an operating system buffer that waits until enough data has been gathered or something like that?
Well, if I execute the command from CMD, I get live stream output (which is dots presented on the screen - one dot for every second). But via nodejs I get them all in a single output once the command's finished.
Can you give any more information about what kind of program you are running? At first I thought that the frct that you used ls in the code snippet means that you run, well, ls, but that doesn’t seem to be the case?