![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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...*... |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|