Posted By

viatropos on 08/16/10


Tagged

Shell unix nodejs


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

capsella


Execute a Unix Command with Node.js


 / Published in: JavaScript
 

URL: execute-a-unix-command-with-node-js

  1. // http://nodejs.org/api.html#_child_processes
  2. var sys = require('sys')
  3. var exec = require('child_process').exec;
  4. var child;
  5.  
  6. // executes `pwd`
  7. child = exec("pwd", function (error, stdout, stderr) {
  8. sys.print('stdout: ' + stdout);
  9. sys.print('stderr: ' + stderr);
  10. if (error !== null) {
  11. console.log('exec error: ' + error);
  12. }
  13. });

Report this snippet  

You need to login to post a comment.