![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| if not working correctly | 2dumb | Shell Programming and Scripting | 3 | 05-03-2007 02:38 PM |
| HP-UX will not boot correctly | pantas manik | HP-UX | 1 | 05-30-2006 02:51 AM |
| Couldn't set locale correctly | mattd | UNIX for Dummies Questions & Answers | 1 | 02-10-2004 05:11 PM |
| Script not working correctly | elchalateco | UNIX for Dummies Questions & Answers | 2 | 10-11-2002 04:09 PM |
| why the PATH can not be set correctly? | yishen | UNIX for Dummies Questions & Answers | 5 | 07-23-2002 10:09 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Script not running correctly
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
|
|
||||
|
figured it out...
my 'exit' and 'fi' was in the wrong place..:P... moved it to the end of the script. Works not. *Result of staring at the code for too long...hehehe...overlook small mistakes...*... ![]() |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|