Created
April 24, 2012 02:37
-
-
Save danvega/2475691 to your computer and use it in GitHub Desktop.
NodeJs Tail to browser window
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 http = require('http'); | |
var spawn = require('child_process').spawn; | |
http.createServer(function(request,response){ | |
response.writeHead(200,{ | |
'Content-Type' : 'text/plain' | |
}); | |
var directory = 'C:\\ColdFusion9\\logs\\'; | |
var filename = process.argv[2]; | |
if( filename ) { | |
var tail_child = spawn('powershell', ['Get-Content',directory + filename + '.log','-Wait'] ); | |
tail_child.stdout.on('data',function(data){ | |
console.log(data.toString()); | |
response.write(data); | |
}); | |
} else { | |
console.log("Please pass in the name of the log you want to read"); | |
} | |
}).listen(8000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment