Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
REMitchell
GitHub Repository: REMitchell/python-crawling
Path: blob/master/6-Selenium/phantomjs/examples/child_process-examples.js
164 views
1
var spawn = require("child_process").spawn
2
var execFile = require("child_process").execFile
3
4
var child = spawn("ls", ["-lF", "/rooot"])
5
6
child.stdout.on("data", function (data) {
7
console.log("spawnSTDOUT:", JSON.stringify(data))
8
})
9
10
child.stderr.on("data", function (data) {
11
console.log("spawnSTDERR:", JSON.stringify(data))
12
})
13
14
child.on("exit", function (code) {
15
console.log("spawnEXIT:", code)
16
})
17
18
//child.kill("SIGKILL")
19
20
execFile("ls", ["-lF", "/usr"], null, function (err, stdout, stderr) {
21
console.log("execFileSTDOUT:", JSON.stringify(stdout))
22
console.log("execFileSTDERR:", JSON.stringify(stderr))
23
})
24
25
setTimeout(function () {
26
phantom.exit(0)
27
}, 2000)
28
29