The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts 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 11:38 AM
HP-UX will not boot correctly pantas manik HP-UX 1 05-29-2006 11:51 PM
Couldn't set locale correctly mattd UNIX for Dummies Questions & Answers 1 02-10-2004 02:11 PM
Script not working correctly elchalateco UNIX for Dummies Questions & Answers 2 10-11-2002 01:09 PM
why the PATH can not be set correctly? yishen UNIX for Dummies Questions & Answers 5 07-23-2002 07:09 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-25-2008
Registered User
 

Join Date: Jan 2008
Posts: 7
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
Reply With Quote
Forum Sponsor
  #2  
Old 01-25-2008
Registered User
 

Join Date: Jan 2008
Posts: 7
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...*...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0