HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script error
Operating System - HP-UX
1834970
Members
2011
Online
110072
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2008 09:52 PM
05-31-2008 09:52 PM
Script error
Hi All,
I have created that script and when i executed this script i have soome error below i am mentioning the script as well as error.
SR1> vi chkalert.sh
"chkalert.sh" 66 lines, 1143 characters
clear
# Script checks for ORA error in alert log file
# Error occured Post midnight
# Date : May 29 2008
DT=`date '+%b %d'`
export DT
#
# Mention Alert file location
#
ALR_LOG=/ora9/home/dba/oracle/admin/mul/bdump
export ALR_LOG
# echo $DT $ALR_LOG
#
# Count Total number of lines in log file
#
A=`wc -l $ALR_LOG|awk '{print \$1}'`
# echo $A
#
# Find Line number when Today's first entry started in log file
#
B=`grep -n "$DT" $ALR_LOG|head -1|awk -F: '{print \$1}'`
#
# Store total lines to be displayed from tail of log file by doing minus on A and B value
#
TAIL=`echo $A $B - p |dc`
# echo $TAIL
#
# Display the ORA Error
#
echo
echo "################ Total ORA error Occurance Between Midnight and Now ############"
echo
tail -f $TAIL $ALR_LOG|awk '/^ORA/{print}'
#
echo
echo "###### Display all distinct errrors ###########"
#
tail -f $TAIL $ALR_LOG|awk '/^ORA/{print}' |sort|uniq
#
# Alert when error is not from below List
#
echo
echo "######## Alert when error is not from below List #############"
echo
echo " ORA -00060 "
echo " ORA-02396 "
echo
echo " ###################### - - - ##################### "
"chkalert.sh" 66 lines, 1141 characters
SR1>
SR1>
SR1>
SR1> ./chkalert.sh
################ Total ORA error Occurance Between Midnight and Now ############
tail: Can only process one file at a time.
Usage: tail [-f] [-c number|-n number|-m number|-b number|-k number] [file]
Usage: tail [-r] [-n number] [file]
Usage: tail [+|-[number]][l|b|c|k|m][f] [file]
###### Display all distinct errrors ###########
tail: Can only process one file at a time.
Usage: tail [-f] [-c number|-n number|-m number|-b number|-k number] [file]
Usage: tail [-r] [-n number] [file]
Usage: tail [+|-[number]][l|b|c|k|m][f] [file]
######## Alert when error is not from below List #############
ORA -00060
ORA-02396
###################### - - - #####################
Please reply as soon as possible
regards,
I have created that script and when i executed this script i have soome error below i am mentioning the script as well as error.
SR1> vi chkalert.sh
"chkalert.sh" 66 lines, 1143 characters
clear
# Script checks for ORA error in alert log file
# Error occured Post midnight
# Date : May 29 2008
DT=`date '+%b %d'`
export DT
#
# Mention Alert file location
#
ALR_LOG=/ora9/home/dba/oracle/admin/mul/bdump
export ALR_LOG
# echo $DT $ALR_LOG
#
# Count Total number of lines in log file
#
A=`wc -l $ALR_LOG|awk '{print \$1}'`
# echo $A
#
# Find Line number when Today's first entry started in log file
#
B=`grep -n "$DT" $ALR_LOG|head -1|awk -F: '{print \$1}'`
#
# Store total lines to be displayed from tail of log file by doing minus on A and B value
#
TAIL=`echo $A $B - p |dc`
# echo $TAIL
#
# Display the ORA Error
#
echo
echo "################ Total ORA error Occurance Between Midnight and Now ############"
echo
tail -f $TAIL $ALR_LOG|awk '/^ORA/{print}'
#
echo
echo "###### Display all distinct errrors ###########"
#
tail -f $TAIL $ALR_LOG|awk '/^ORA/{print}' |sort|uniq
#
# Alert when error is not from below List
#
echo
echo "######## Alert when error is not from below List #############"
echo
echo " ORA -00060 "
echo " ORA-02396 "
echo
echo " ###################### - - - ##################### "
"chkalert.sh" 66 lines, 1141 characters
SR1>
SR1>
SR1>
SR1> ./chkalert.sh
################ Total ORA error Occurance Between Midnight and Now ############
tail: Can only process one file at a time.
Usage: tail [-f] [-c number|-n number|-m number|-b number|-k number] [file]
Usage: tail [-r] [-n number] [file]
Usage: tail [+|-[number]][l|b|c|k|m][f] [file]
###### Display all distinct errrors ###########
tail: Can only process one file at a time.
Usage: tail [-f] [-c number|-n number|-m number|-b number|-k number] [file]
Usage: tail [-r] [-n number] [file]
Usage: tail [+|-[number]][l|b|c|k|m][f] [file]
######## Alert when error is not from below List #############
ORA -00060
ORA-02396
###################### - - - #####################
Please reply as soon as possible
regards,
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2008 10:18 PM
05-31-2008 10:18 PM
Re: Script error
>tail: Can only process one file at a time.
To debug script errors you ask the commands to be echoed. "set -x"
In particular you should echo $TAIL.
General comments on your script:
1) You should start with: #!/usr/bin/sh
2) export DT
No need to export local variables.
3) Replace: A=`wc -l $ALR_LOG|awk '{print \$1}'`
A=$(wc -l < $ALR_LOG)
Note: You don't need a "\" before the "$" if inside ''.
4) B=`grep -n "$DT" $ALR_LOG | head -1| awk -F: '{print \$1}'`
No need for that "\":
B=$(grep -n "$DT" $ALR_LOG | head -1| awk -F: '{print $1}')
You could do it all in awk:
B=$(awk -v DT="$DT" '$0 ~ DT { print NR; exit }'
5) TAIL=`echo $A $B - p |dc`
No need for dc if your files are small. And on 11.23, you don't need to worry:
TAIL=$(( A - B ))
6) tail -f $TAIL $ALR_LOG|awk '/^ORA/{print}' |sort|uniq
grep will work fine here:
tail -f $TAIL $ALR_LOG | grep "^ORA" | sort -u
To debug script errors you ask the commands to be echoed. "set -x"
In particular you should echo $TAIL.
General comments on your script:
1) You should start with: #!/usr/bin/sh
2) export DT
No need to export local variables.
3) Replace: A=`wc -l $ALR_LOG|awk '{print \$1}'`
A=$(wc -l < $ALR_LOG)
Note: You don't need a "\" before the "$" if inside ''.
4) B=`grep -n "$DT" $ALR_LOG | head -1| awk -F: '{print \$1}'`
No need for that "\":
B=$(grep -n "$DT" $ALR_LOG | head -1| awk -F: '{print $1}')
You could do it all in awk:
B=$(awk -v DT="$DT" '$0 ~ DT { print NR; exit }'
5) TAIL=`echo $A $B - p |dc`
No need for dc if your files are small. And on 11.23, you don't need to worry:
TAIL=$(( A - B ))
6) tail -f $TAIL $ALR_LOG|awk '/^ORA/{print}' |sort|uniq
grep will work fine here:
tail -f $TAIL $ALR_LOG | grep "^ORA" | sort -u
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2008 10:25 PM
05-31-2008 10:25 PM
Re: Script error
B=$(awk -v DT="$DT" '$0 ~ DT { print NR; exit }'
Oops, forgot the file:
B=$(awk -v DT="$DT" '$0 ~ DT { print NR; exit }' $ALR_LOG
Oops, forgot the file:
B=$(awk -v DT="$DT" '$0 ~ DT { print NR; exit }' $ALR_LOG
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP