Node.js child_process spawn stdin stdout

Description

Node.js child_process spawn stdin stdout


var spawn=require('child_process').spawn,
  cat=spawn('cat');

cat.stdin.write('hello');

setTimeout(function(){
  cat.stdin.end('bye');
}, 2000);/*from   ww w  . ja v a2 s.com*/

cat.stdout.on('data',function(d){
  console.log('received data on stdout: '+d);
});



PreviousNext

Related