1. Download PhantomJS from here: http://phantomjs.org/
2. On Windows, unzip the archive to your drive and put the path to the phantonjs.exe in your Environment Variables Path:
C:\phantomjs-1.9.0-windows\;
3. Save this as readFile.js
/*jslint indent: 4*/ /*globals document, phantom*/ 'use strict'; var fs = require('fs'), system = require('system'); if (system.args.length < 2) { console.log("Usage: readFile.js FILE"); phantom.exit(1); } var content = '', f = null, lines = null, eol = system.os.name == 'windows' ? "\r\n" : "\n"; try { f = fs.open(system.args[1], "r"); content = f.read(); } catch (e) { console.log(e); } if (f) { f.close(); } if (content) { lines = content.split(eol); for (var i = 0, len = lines.length; i < len; i++) { console.log(lines[i]); } } phantom.exit();
4. Execute it like this:
phantomjs readFile.js filetoread > somefile.txt
You can use this script to open log files, parse out important lines, and save to an HTML file for instance.