BlueGit

blue-star danique-bot

Files

danique-bot / node_modules / phantomjs-prebuilt / lib / phantom / examples / child_process-examples.js

child_process-examples.js

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