mirror of
https://github.com/encounter/phantomjs.git
synced 2026-03-30 11:35:11 -07:00
f52044cd31
This is a rudimentary implementation of the following methods from [node.js's `child_process` module][1]: * `spawn` * `execFile` The examples are relevant only for *nix operating systems... The following methods are Not Yet Implemented™: * `exec` * `fork` [1]: http://nodejs.org/docs/v0.8.16/api/child_process.html http://code.google.com/p/phantomjs/issues/detail?id=219
28 lines
672 B
JavaScript
28 lines
672 B
JavaScript
var spawn = require("child_process").spawn
|
|
var execFile = require("child_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))
|
|
})
|
|
|
|
setTimeout(function () {
|
|
phantom.exit(0)
|
|
}, 2000)
|