Skip to content

Instantly share code, notes, and snippets.

@nanusdad
Created July 26, 2013 00:40
Show Gist options
  • Save nanusdad/6085135 to your computer and use it in GitHub Desktop.
Save nanusdad/6085135 to your computer and use it in GitHub Desktop.
Node JS : continous 'live' stdout example
var util = require('util'),
spawn = require('child_process').spawn,
ls = spawn('ls', ['-lh', '/usr']);
ls.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
ls.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
ls.on('exit', function (code) {
console.log('child process exited with code ' + code);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment