mirror of https://github.com/vitalif/phantomjs
commit
cd0daacccf
|
@ -10,5 +10,28 @@ The child_process module allows you to invoke subprocesses and communicate with
|
|||
To start using, you must `require` a reference to the `child_process` module:
|
||||
|
||||
```javascript
|
||||
var childProcess = require('child_process');
|
||||
var process = require("child_process")
|
||||
var spawn = process.spawn
|
||||
var execFile = process.execFile
|
||||
|
||||
var child = spawn("ls", ["-lF", "/rooot"])
|
||||
|
||||
child.stdout.on("data", function (data) {
|
||||
console.log("spawnSTDOUT:", JSON.stringify(data))
|
||||
})
|
||||
|
||||
child.stderr.on("data", function (data) {
|
||||
console.log("spawnSTDERR:", JSON.stringify(data))
|
||||
})
|
||||
|
||||
child.on("exit", function (code) {
|
||||
console.log("spawnEXIT:", code)
|
||||
})
|
||||
|
||||
//child.kill("SIGKILL")
|
||||
|
||||
execFile("ls", ["-lF", "/usr"], null, function (err, stdout, stderr) {
|
||||
console.log("execFileSTDOUT:", JSON.stringify(stdout))
|
||||
console.log("execFileSTDERR:", JSON.stringify(stderr))
|
||||
})
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue