Skip to content

Instantly share code, notes, and snippets.

@russelyang
Created May 22, 2011 15:51
Show Gist options
  • Save russelyang/985606 to your computer and use it in GitHub Desktop.
Save russelyang/985606 to your computer and use it in GitHub Desktop.
node.js child_process sample
//var child = process.createChildProcess('sh',
// ['-c', 'echo hello; sleep 1; echo world;']);
//child.addListener('data', function(chunk) {
// console.log(chunk);
//});
var spawn = require('child_process').spawn,
child = spawn('sh', ['-c', 'echo hello; sleep 1; echo world;']);
child.stdout.on('data', function(chunk) {
console.log(chunk.toString());
});
child.on('exit', function(code) {
console.log('child process exited with code' + code);
});
@khue20
Copy link

khue20 commented Sep 14, 2021

I don't understand please give me more example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment