| 1 | "use strict"; |
| 2 | var spawn = require("child_process").spawn |
| 3 | var execFile = require("child_process").execFile |
| 4 | |
| 5 | var child = spawn("ls", ["-lF", "/rooot"]) |
| 6 | |
| 7 | child.stdout.on("data", function (data) { |
| 8 | console.log("spawnSTDOUT:", JSON.stringify(data)) |
| 9 | }) |
| 10 | |
| 11 | child.stderr.on("data", function (data) { |
| 12 | console.log("spawnSTDERR:", JSON.stringify(data)) |
| 13 | }) |
| 14 | |
| 15 | child.on("exit", function (code) { |
| 16 | console.log("spawnEXIT:", code) |
| 17 | }) |
| 18 | |
| 19 | //child.kill("SIGKILL") |
| 20 | |
| 21 | execFile("ls", ["-lF", "/usr"], null, function (err, stdout, stderr) { |
| 22 | console.log("execFileSTDOUT:", JSON.stringify(stdout)) |
| 23 | console.log("execFileSTDERR:", JSON.stringify(stderr)) |
| 24 | }) |
| 25 | |
| 26 | setTimeout(function () { |
| 27 | phantom.exit(0) |
| 28 | }, 2000) |