<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Script Errors in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863603#M705779</link>
    <description>The intention is that the ($1 == "Root:") will always match the first line after the list of devices in the "PV_Name:" section.  That seems like a reasonable assumption based on the sample data.  Seeing "Root:" will turn off STAND_CHECK for the rest of the lines in the file.&lt;BR /&gt;&lt;BR /&gt;  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.&lt;BR /&gt;&lt;BR /&gt;  Note that you can also see a line like this, which the awk script handles correctly-&lt;BR /&gt;Boot: lvol1 on:  /dev/dsk/c0t3d0&lt;BR /&gt;</description>
    <pubDate>Fri, 01 Oct 2004 18:12:51 GMT</pubDate>
    <dc:creator>Mike Stroyan</dc:creator>
    <dc:date>2004-10-01T18:12:51Z</dc:date>
    <item>
      <title>Script Errors</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863599#M705775</link>
      <description>&lt;BR /&gt;I have a script written by someone else and I just would like a "second-eye" opinion from you folks.&lt;BR /&gt;&lt;BR /&gt;The objective of the script is to test and confirm all the /stand volumes (Primary and Mirror) are referred in the BDRA of VG00.&lt;BR /&gt;&lt;BR /&gt;I kinda figured out what is wrong with the script. There is one typo and one "logical" error in the AWK statement.&lt;BR /&gt;&lt;BR /&gt;Before escalating this problem to the script's author, I just wanted to confirm. I dont want to embarrass myself :-).&lt;BR /&gt;&lt;BR /&gt;Anyone who spots the errors will be awarded bunnies :-)&lt;BR /&gt; &lt;BR /&gt;==============================================&lt;BR /&gt;BOOT_HEADER=/tmp/boot.$$&lt;BR /&gt;STAND_DEVS="/dev/dsk/c1t6d0 /dev/dsk/c2t6d0"&lt;BR /&gt;lvlnboot -v vg00 | sed 's/PV Name/PV_Name/g' &amp;gt; $BOOT_HEADER 2&amp;gt;/dev/null&lt;BR /&gt;        STATUS=""&lt;BR /&gt;        echo "Checking BOOT DISK definitions: \c"&lt;BR /&gt;        for BOOTING_DEVICE in $STAND_DEVS&lt;BR /&gt;        do&lt;BR /&gt;                CHECK_COUNT=$(cat $BOOT_HEADER | grep "Boot Disk" | grep $BOOTING_DEVICE| wc -l)&lt;BR /&gt;                case $CHECK_COUNT in&lt;BR /&gt;                        1)      STATUS="OK";;&lt;BR /&gt;                        0)      STATUS="ERROR - $BOOTING_DEVICE not defined.";;&lt;BR /&gt;                        *)      STATUS="ERROR - multiple entries defined for $BOOTING_DEVICE"&lt;BR /&gt;                esac&lt;BR /&gt;        done&lt;BR /&gt;        echo $STATUS&lt;BR /&gt;        STATUS=""&lt;BR /&gt;        echo "Checking BOOT LV(stand) definition: \c"&lt;BR /&gt;        for STAND_DEVICE in $STAND_DEVS&lt;BR /&gt;        do&lt;BR /&gt;                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) &amp;amp;&amp;amp; (NF == 4)) {print $4} if ((ST&lt;BR /&gt;AND_CHECK == 1) &amp;amp;&amp;amp; (NF == 1)) {print $1}}' | grep -c $STAND_DEVICE)&lt;BR /&gt;                case $CHECK_COUNT in&lt;BR /&gt;                        1)      STATUS="OK";;&lt;BR /&gt;                        0)      STATUS="ERROR - $STAND_DEVICE not defined.";;&lt;BR /&gt;                        *)      STATUS="ERROR - multiple entries defined for $STAND_DEVICE"&lt;BR /&gt;                esac&lt;BR /&gt;        done&lt;BR /&gt;        echo $STATUS&lt;BR /&gt;==============================================&lt;BR /&gt;# ./script&lt;BR /&gt;Checking BOOT DISK definitions: OK&lt;BR /&gt;Checking BOOT LV(stand) definition: ERROR - /dev/dsk/c2t6d0 not defined.&lt;BR /&gt;#&lt;BR /&gt;# lvlnboot -v /dev/vg00&lt;BR /&gt;Boot Definitions for Volume Group /dev/vg00:&lt;BR /&gt;Physical Volumes belonging in Root Volume Group:&lt;BR /&gt;        /dev/dsk/c1t6d0 (0/0/2/0.6.0) -- Boot Disk&lt;BR /&gt;        /dev/dsk/c2t6d0 (0/0/2/1.6.0) -- Boot Disk&lt;BR /&gt;PV Name: lvol1  on:     /dev/dsk/c1t6d0&lt;BR /&gt;                        /dev/dsk/c2t6d0&lt;BR /&gt;Root: lvol3     on:     /dev/dsk/c1t6d0&lt;BR /&gt;                        /dev/dsk/c2t6d0&lt;BR /&gt;Swap: lvol2     on:     /dev/dsk/c1t6d0&lt;BR /&gt;                        /dev/dsk/c2t6d0&lt;BR /&gt;Dump: lvol2     on:     /dev/dsk/c1t6d0, 0&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;=============================================</description>
      <pubDate>Fri, 01 Oct 2004 16:32:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863599#M705775</guid>
      <dc:creator>Sundar_7</dc:creator>
      <dc:date>2004-10-01T16:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Script Errors</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863600#M705776</link>
      <description>The check for $1 == "PV_Name" should be&lt;BR /&gt;$1 == "PV_Name:"&lt;BR /&gt;&lt;BR /&gt;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.</description>
      <pubDate>Fri, 01 Oct 2004 17:09:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863600#M705776</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2004-10-01T17:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: Script Errors</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863601#M705777</link>
      <description>The script also seems to be leaving the /tmp/boot.$$ file lying around.  It should clean that up.</description>
      <pubDate>Fri, 01 Oct 2004 17:11:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863601#M705777</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2004-10-01T17:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Script Errors</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863602#M705778</link>
      <description>Mike,&lt;BR /&gt;  &lt;BR /&gt;  You got the first one right on.&lt;BR /&gt;&lt;BR /&gt;  I do see one major problem with the awk statement&lt;BR /&gt;&lt;BR /&gt;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) &amp;amp;&amp;amp; (NF == 4)) {print $4} if ((ST&lt;BR /&gt;AND_CHECK == 1) &amp;amp;&amp;amp; (NF == 1)) {print $1}}' | grep -c $STAND_DEVICE)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  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.&lt;BR /&gt;&lt;BR /&gt;  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 ?&lt;BR /&gt;&lt;BR /&gt;- Sundar</description>
      <pubDate>Fri, 01 Oct 2004 17:23:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863602#M705778</guid>
      <dc:creator>Sundar_7</dc:creator>
      <dc:date>2004-10-01T17:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Script Errors</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863603#M705779</link>
      <description>The intention is that the ($1 == "Root:") will always match the first line after the list of devices in the "PV_Name:" section.  That seems like a reasonable assumption based on the sample data.  Seeing "Root:" will turn off STAND_CHECK for the rest of the lines in the file.&lt;BR /&gt;&lt;BR /&gt;  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.&lt;BR /&gt;&lt;BR /&gt;  Note that you can also see a line like this, which the awk script handles correctly-&lt;BR /&gt;Boot: lvol1 on:  /dev/dsk/c0t3d0&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Oct 2004 18:12:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863603#M705779</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2004-10-01T18:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: Script Errors</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863604#M705780</link>
      <description>Mike: - I understand how awk processes if sentense in the same line :-). What I missed out, was that STAND_CHECK remains set to 0, for rest of the lines.</description>
      <pubDate>Fri, 01 Oct 2004 18:16:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863604#M705780</guid>
      <dc:creator>Sundar_7</dc:creator>
      <dc:date>2004-10-01T18:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: Script Errors</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863605#M705781</link>
      <description>See my above posts.</description>
      <pubDate>Fri, 01 Oct 2004 18:23:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-errors/m-p/4863605#M705781</guid>
      <dc:creator>Sundar_7</dc:creator>
      <dc:date>2004-10-01T18:23:36Z</dc:date>
    </item>
  </channel>
</rss>

