Skip to content

Instantly share code, notes, and snippets.

@gjohnson
Created March 18, 2011 15:33
Show Gist options
  • Save gjohnson/876279 to your computer and use it in GitHub Desktop.
Save gjohnson/876279 to your computer and use it in GitHub Desktop.
web interface for tail
var sys = require('sys');
var child = require('child_process');
var http = require('http');
var filename = process.ARGV[2];
if (!filename) {
return sys.puts('usage: node tail.js filename');
}
var tail = child.spawn("tail", ["-f", filename]);
var server = http.createServer(function(request, response){
response.writeHead(200, {'Content-Type': 'text/plain'});
response.write("Hello!");
tail.stdout.on('data', function(data){
response.write(data);
});
});
server.listen(3000);
console.log('server running on port 3000');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment