Created
February 25, 2016 14:16
-
-
Save nomeyer/90ce9b321fbf8cbff3da to your computer and use it in GitHub Desktop.
Spawn a child process with command line arguments in node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const spawn = require('child_process').spawn; | |
const ls = spawn('ls', ['-lh', '/usr']); | |
ls.stdout.on('data', (data) => { | |
console.log(`stdout: ${data}`); | |
}); | |
ls.stderr.on('data', (data) => { | |
console.log(`stderr: ${data}`); | |
}); | |
ls.on('close', (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