1 fansekey 2014-07-23 19:01:01 +08:00 var spawn = require('child_process').spawn; var h = spawn('ls', ['-l', '.']); h.stdout.on('data', function (s) { console.log(s.toString()); }); h.stdout.on('end', function () { console.log('ls done'); }); 可以这么做;子进程的h.stdout其实是个流,你可以这么边执行边获取子进程的标准输出。 |
2 stormslowly 2014-07-24 13:52:26 +08:00 h.stdout.pipe( your stream handler goes here ) |