Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
47
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.     //request.connection.on('end', function() {tail_child_kill();});
  13.  
  14.     tail_child.stdout.on('data', function(data) {
  15.             console.log(data.toString());
  16.             response.write(data);
  17.         });
  18.  
  19. }
  20.  
  21. function onData(data)
  22. {  
  23.     console.log(data.toString());
  24.     response.write(data);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement