ログ ファイルを、「誰でも」アクセスできる、見やすい .html ファイルに変換するスクリプトが必要です。
これが私がこれまでに持っているものです:
#!/bin/bash
## The purpose of this script is to create .html files from log files, with the ability to optionally GREP for certain strings
if [ "$2" == "" ];
then
echo "Usage : $0 [Source Log file] [Output HTML file] [String to grep (if applicable)]"
exit 255
fi;
LOGFILE=$1
OUTPUTFILE=$2
GREPSTRING=$3
if [ "$3" == "" ];
then
echo "Cat'ing $LOGFILE to $OUTPUTFILE"
LOGCONTENTS=`cat $LOGFILE`
else
echo "Grep'ing for $GREPSTRING in $LOGFILE"
LOGCONTENTS=`grep --color $GREPSTRING $LOGFILE | sed -e "s/^.*$/&1\n/"`
fi;
# Below is the html heading which will be appended to the final .html file
HEADING="<html><body><h1>Log output for: $LOGFILE</h1>"
# Below is the end of the html file
END="</body></html>"
# Below all the prepared variables are stitched together to the OUTPUT/LOG FILE
echo $HEADING > $OUTPUTFILE
echo $LOGCONTENTS >> $OUTPUTFILE
echo $END >> $OUTPUTFILE
# For debugging, enable the lines below
echo $LOGCONTENTS
echo "Done preparing $OUTPUTFILE"
私の問題は、CAT、GREP、SED などでいくら遊んでも、出力で改行が保持されないことです。通常の tail -f または cat を実行するときとほぼ同じように出力ファイルを表示することが不可欠です。