I'm new to node.js and trying to execute two processes in a row, the first process' stdout piped into the second's stdin. And then the second process' stdout should be piped into variable res as the response to a URL request. Code is here. Part of it is written by someone else so maybe I have misunderstanding:
var sox = spawn("sox", soxArgs)
var rubberband = spawn("rubberband", rubberbandArgs)
sox.stdout.pipe(rubberband.stdin)
rubberband.stdout.pipe(res) #won't send to res anything, why?
#rubberband.stdin.pipe(res) won't send to res anything, either!
#sox.stdout.pipe(res) will work just fine
sox.stdin.write(data)
sox.stdin.end()
#the actual sox process will not execute until sox.stdin is filled with data..?
Any help would be appreciated! I've spent hours looking into this!
I think the solution you are looking for is piping stdin to stdout from https://nodejs.org/api/process.html#process_process_stdin :
process.stdin.on('readable', () => {
const chunk = process.stdin.read();
if (chunk !== null) {
process.stdout.write(`data: ${chunk}`);
}
});
process.stdin.on('end', () => {
process.stdout.write('end');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With