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 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 03:38 PM
HP-UX will not boot correctly pantas manik HP-UX 1 05-30-2006 03: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 05:09 PM
why the PATH can not be set correctly? yishen UNIX for Dummies Questions & Answers 5 07-23-2002 11:09 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 01-25-2008
phixsius phixsius is offline
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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:02 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0