Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var http = require('http');
  2. var spawn = require('child_process').spawn;
  3.  
  4. http.createServer(onRequest).listen(4000);
  5.  
  6. function onRequest(request, response)
  7. {  
  8.     response.writeHead(200, {'Content-Type' : 'text/plain'});
  9.  
  10.     var tail_child = spawn('tail', ['-f', '/var/log/system.log']);
  11.  
  12.     tail_child.stdout.on('data', onData);
  13.  
  14. }
  15.  
  16. function onData(data)
  17. {
  18.     console.log(data.toString());
  19.     response.write(data);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement