I am running a linux ping command as a child process using the node.js code below.
The ping command has to be continuous and normally displays the ping result every second when running in a console.
The last line of code simply pipes the output to the console as if the command had been issued on a console.
I need to parse the ping results as they come in in node.js.
Possible Solution : I think that this can possibly be done by creating a duplex stream, piping the "ping output" to the duplex stream and reading on an "available" event.
I cannot get the above working! The first problem I run into is the lack of documentation on creating an instance for a duplex stream.
==
var exec = require('child_process').exec,
child;
child = exec('ping 192.168.1.82',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
child.stdout.pipe(process.stdout);