- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script Errors
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- 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
тАО10-01-2004 09:32 AM
тАО10-01-2004 09:32 AM
I have a script written by someone else and I just would like a "second-eye" opinion from you folks.
The objective of the script is to test and confirm all the /stand volumes (Primary and Mirror) are referred in the BDRA of VG00.
I kinda figured out what is wrong with the script. There is one typo and one "logical" error in the AWK statement.
Before escalating this problem to the script's author, I just wanted to confirm. I dont want to embarrass myself :-).
Anyone who spots the errors will be awarded bunnies :-)
==============================================
BOOT_HEADER=/tmp/boot.$$
STAND_DEVS="/dev/dsk/c1t6d0 /dev/dsk/c2t6d0"
lvlnboot -v vg00 | sed 's/PV Name/PV_Name/g' > $BOOT_HEADER 2>/dev/null
STATUS=""
echo "Checking BOOT DISK definitions: \c"
for BOOTING_DEVICE in $STAND_DEVS
do
CHECK_COUNT=$(cat $BOOT_HEADER | grep "Boot Disk" | grep $BOOTING_DEVICE| wc -l)
case $CHECK_COUNT in
1) STATUS="OK";;
0) STATUS="ERROR - $BOOTING_DEVICE not defined.";;
*) STATUS="ERROR - multiple entries defined for $BOOTING_DEVICE"
esac
done
echo $STATUS
STATUS=""
echo "Checking BOOT LV(stand) definition: \c"
for STAND_DEVICE in $STAND_DEVS
do
CHECK_COUNT=$(cat $BOOT_HEADER | awk 'BEGIN {STAND_CHECK=0} { if ($1 == "PV_Name" || $1 == "Boot:") {STAND_CHECK=1} if ($1 == "Root:") {STAND_CHECK=0} if ((STAND_CHECK == 1) && (NF == 4)) {print $4} if ((ST
AND_CHECK == 1) && (NF == 1)) {print $1}}' | grep -c $STAND_DEVICE)
case $CHECK_COUNT in
1) STATUS="OK";;
0) STATUS="ERROR - $STAND_DEVICE not defined.";;
*) STATUS="ERROR - multiple entries defined for $STAND_DEVICE"
esac
done
echo $STATUS
==============================================
# ./script
Checking BOOT DISK definitions: OK
Checking BOOT LV(stand) definition: ERROR - /dev/dsk/c2t6d0 not defined.
#
# lvlnboot -v /dev/vg00
Boot Definitions for Volume Group /dev/vg00:
Physical Volumes belonging in Root Volume Group:
/dev/dsk/c1t6d0 (0/0/2/0.6.0) -- Boot Disk
/dev/dsk/c2t6d0 (0/0/2/1.6.0) -- Boot Disk
PV Name: lvol1 on: /dev/dsk/c1t6d0
/dev/dsk/c2t6d0
Root: lvol3 on: /dev/dsk/c1t6d0
/dev/dsk/c2t6d0
Swap: lvol2 on: /dev/dsk/c1t6d0
/dev/dsk/c2t6d0
Dump: lvol2 on: /dev/dsk/c1t6d0, 0
#
=============================================
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-01-2004 10:09 AM
тАО10-01-2004 10:09 AM
Solution$1 == "PV_Name:"
The STATUS is overwritten every time through the loop, so only the STATUS from the last device is reported. The loop could report an error message immediately for each error. It could also set a flag to suppress a final "OK" message that would be printed after a successful loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-01-2004 10:11 AM
тАО10-01-2004 10:11 AM
Re: Script Errors
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-01-2004 10:23 AM
тАО10-01-2004 10:23 AM
Re: Script Errors
You got the first one right on.
I do see one major problem with the awk statement
CHECK_COUNT=$(cat $BOOT_HEADER | awk 'BEGIN {STAND_CHECK=0} { if ($1 == "PV_Name" || $1 == "Boot:") {STAND_CHECK=1} if ($1 == "Root:") {STAND_CHECK=0} if ((STAND_CHECK == 1) && (NF == 4)) {print $4} if ((ST
AND_CHECK == 1) && (NF == 1)) {print $1}}' | grep -c $STAND_DEVICE)
Here, author is trying to print the device files linked as /stand in BDRA. AWK sets the STAND_CHECK to 1 when it sees "PV_Name" in $1, to 0 when it sees "Root:" and prints the device file ($4 and $1) whenever STAND_CHECK == 1.
I think the AWK statement should set STAND_CHECK to 0 when it sees anything other than "PV_Name" in $1. With the current code, STAND_CHECK will stand set to 1, even when it is parsing "Swap:" and "Dump:" ?? right ?
- Sundar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-01-2004 11:12 AM
тАО10-01-2004 11:12 AM
Re: Script Errors
The awk script will correctly accept an arbitrary number of lines that list one device file per line after a "PV_Name:" line. When reading the awk script remember that more than one of the 'if' lines can apply to a single line of input. The test for "PV_Name:" and "Boot:" turn on STAND_CHECK, which applies immediately to the (NF == 4) test on the same line of input.
Note that you can also see a line like this, which the awk script handles correctly-
Boot: lvol1 on: /dev/dsk/c0t3d0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-01-2004 11:16 AM
тАО10-01-2004 11:16 AM
Re: Script Errors
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-01-2004 11:23 AM
тАО10-01-2004 11:23 AM