Wednesday, March 25, 2015

weechat log to html script

and in your handy cron job you run this to convert your logs and make an index from your mosh screen weechat log thing. irclog2html doesn't like ~ by-the-by.
   
 #!/bin/bash  
 # parse logs to html  
 # remove hashes from names  
 # create prettified index from directory list  
   
 title="irc logs"  
 dest=~/public_html/logs  
   
 # parse  
 irclog2html --title=' ' --index-url='index.html' --index-title='irc logs' -o '/full/pwd/to/public_html/logs/' /full/pwd/to/.weechat/logs/*.log  
   
 # rename  
 cd $dest  
 rename -f 's/[^A-Za-z0-9._-]//g' *  
   
 # create index  
 echo "<html>" > $dest/index.html  
 echo "<title>$title</title>" >> $dest/index.html  
 echo "<body>" >> $dest/index.html  
 echo "<h3>$title</h3>" >> $dest/index.html  
   
 ls $dest | grep -vE '(index.html|irclog.css|*core*)' | awk -F"." '{print "<a href=" $1 "." $2 "." $3 "." $4 ".html>" $1 "." $2 "." $3 "." $4 "</a><br>"}' \  
 >> $dest/index.html  
   
 echo "</body></html>" >> $dest/index.html  
   
Post a Comment