I'm still up trying to figure this out and it is driving me nuts.
I have a log file which has a basic format of this...
2010-10-10 22:25:42
[Error: 43059] Init block 'UA Deployment Date': Dynamic refresh of repository scope variables has failed.
[Error: 16024] The ODBC function has returned an error. The database may not be available, or the network may be down.
2010-12-10 22:25:42
[Error: 43059] Init block 'Current Usage Accelerator Refresh Date': Dynamic refresh of repository scope variables has failed.
[Error: 16023] The ODBC function has returned an error. The database may not be available, or the network may be down.
2010-12-11 22:25:42
[Error: 43059] Init block 'New Activity Interval for Asset': Dynamic refresh of repository scope variables has failed.
[Error: 16023] The ODBC function has returned an error. The database may not be available, or the network may be down.
2010-12-11 22:25:42
[Error: 43059] Init block 'New Activity Interval for Account': Dynamic refresh of repository scope variables has failed.
[Error: 16024] The ODBC function has returned an error. The database may not be available, or the network may be down.
2010-12-13 22:25:42
[Error: 43059] Init block 'New Activity Interval for Opportunity': Dynamic refresh of repository scope variables has failed.
[Error: 16024] The ODBC function has returned an error. The database may not be available, or the network may be down.
I have a date which I return from Oracle in the exact same format as this log file in a variable called $lastdate. I was able to use grep to store the log date into $logdate.
I have to go through this logfile starting at the point where $logdate > $lastdate and only return the whole error message of error 16024 or 16023(ex: [Error: 16024] The ODBC function has returned an error. The database may not be available, or the network may be down.). I'm going nuts trying to figure out how to do the > operator between dates and then only getting the 16024 or 16023 error.
This is my code thus far which obviously doesnt work very well:
tail -f $logfile |
while read LINE; do
if echo $LINE | grep ^20..'-'..'-'.. >/dev/null; then
logdate=$LINE
echo " the log date is: ========== $logdate ============="
if ['$logdate'<'$lastdate']; then
if echo $LINE | grep '16024' >/dev/null; then
echo " ========= I find the error =================================: $LINE"
# echo $LINE | cut -d "|" -f > $tempfile
fi
fi
# if echo $LINE | date >/dev/null; then
# lastrun=$LINE
# echo " ========= Last run date is=================================: $lastrun"
# if [$lastrun < $lastdate ]; then
# echo " Last run date is less than last date"
# if echo $LINE | grep ^20..'-'..'-'.. >/dev/null; then
# linecount=$(($linecount + 1))
# echo " I find the line: $LINE"
# echo $LINE | cut -d "|" -f > $tempfile
# breakdown=$(echo $LINE | cut -d "]" -f 1)
# echo "$LINE" >> $tempfile
# echo "The break down is: $breakdown"
# fi
else
echo " Last run date is larger than last date"
fi
# fi
exit 0
done<$logfile