Created
March 18, 2011 15:33
-
-
Save gjohnson/876279 to your computer and use it in GitHub Desktop.
web interface for tail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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