Hi all,
My script below was working fine till I changed the LOGFILE path (which originally points to a file within the same folder of the script for testing)
Only the event.log file path is changed, the rest are still within the current folder.
Before the change, running the script works. After the change, from the "
sed" commands onwards, it doesn't seem to trigger.
I separated the '
sed' part to another script, and ran that on its own, therefore, the commands work.
But somehow putting it together seems to give me a major headache.
Need help quickly.
Thanks.
Code:
#!/bin/sh
integer CURCOUNT
LOGFILE=/var/opt/resmon/log/event.log
#Compare current count line with old count line in oldcount.txt
OLDCOUNT=`cat oldcount.txt | awk '{print $1}'`
CURCOUNT=`wc -l /var/opt/resmon/log/event.log | awk '{print $1}`
if [ "$CURCOUNT" = "$OLDCOUNT" ]; then
echo "NO Change"
exit
else
NEWLINES=`expr $CURCOUNT - $OLDCOUNT`
# Read and output new lines to diffline.txt
STARTLINE=`expr $OLDCOUNT + 1`
LASTLINE=$CURCOUNT
awk -v SL=$STARTLINE -v LL=$LASTLINE '
((NR >=SL) && (NR <=LL)) {print $0}' /var/opt/resmon/log/event.log > diffline.txt
#Updates oldcount.txt with latest value
echo $CURCOUNT > oldcount.txt
exit
fi
sed -ne '/^---/p' -e '/Severity............: CRITICAL/,/^Description of Error/p' -e '/Severity............: MAJORWARNING/,/^Description of Er
ror/p' diffline.txt | sed -ne '/^Severity/p' -e '/^Summary/,/^Description of Error/p' | sed '/^Description/d' | sed '/^$/d' | sed 's/^[ \t]*/
/;s/[ \t]*$//' > diffline2.txt
sed -n '
:a
/Sev/ {
N
/Sev.*Sev/ !{
s/\n/ /
ta
}
P
D
}' diffline2.txt > diffline3.txt