Say I have a named pipe on linux:
mkfifo lk.log
From the command line, I can do this to print out anything written to the name pipe file.
node monitor.js < lk.log
and pretend this is what the script looks like
// monitor.js
process.stdin.resume();
process.stdin.setEncoding('utf8');
// read data from stdin
process.stdin.on('data', function(chunk) {
console.log(chunk);
});
How could I do this within node using child_process.spawn
?
child_process.spawn('node', ['monitor.js'])...