public
Created

exec in server request handler

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14
var exec = require("child_process").exec;
require('http').createServer(function(req, response) {
 
console.log("Request handler 'start' was called.");
var content = "empty";
 
exec("ls -lah", function(error, stdout, stderr) {
response.writeHead(200, {"Content-type":"text/plain"});
response.write(stdout);
console.log(stdout);
response.end();
});
 
}).listen(5555);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.