child_process-examples.coffee 549 B

1234567891011121314151617181920
  1. {spawn, execFile} = require "child_process"
  2. child = spawn "ls", ["-lF", "/rooot"]
  3. child.stdout.on "data", (data) ->
  4. console.log "spawnSTDOUT:", JSON.stringify data
  5. child.stderr.on "data", (data) ->
  6. console.log "spawnSTDERR:", JSON.stringify data
  7. child.on "exit", (code) ->
  8. console.log "spawnEXIT:", code
  9. #child.kill "SIGKILL"
  10. execFile "ls", ["-lF", "/usr"], null, (err, stdout, stderr) ->
  11. console.log "execFileSTDOUT:", JSON.stringify stdout
  12. console.log "execFileSTDERR:", JSON.stringify stderr
  13. setTimeout (-> phantom.exit 0), 2000