<?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 question here in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589310#M880141</link>
    <description>Sanman,&lt;BR /&gt;&lt;BR /&gt;Check the line&lt;BR /&gt;&lt;BR /&gt;FAIL_CODE=$(ssh $i "tail -1 /var/opt/ignite/logs/makrec.log1 2&amp;gt; /dev/null | grep 'Ended' 'makrec.log1' | tail -1") &lt;BR /&gt;&lt;BR /&gt;Also, 'makrec.log1' in the above should give you an error that makrec.log1 not found.&lt;BR /&gt;&lt;BR /&gt;tail -1 gives you ****** . You may need to make it tail -2.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
    <pubDate>Wed, 03 Oct 2001 18:11:08 GMT</pubDate>
    <dc:creator>Sridhar Bhaskarla</dc:creator>
    <dc:date>2001-10-03T18:11:08Z</dc:date>
    <item>
      <title>script question here</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589309#M880140</link>
      <description>Hello guys. Help me with this script here. What I should be able to do in the end is, if my make recovery is sucessful, I want my table to display a green color and when it ends uncessful, it needs to show a red color. What is wrong with my script. &lt;BR /&gt;&lt;BR /&gt;# Get the start time&lt;BR /&gt;&lt;BR /&gt; ssh $i "tail -10 /var/opt/ignite/logs/makrec.log1 2&amp;gt; /dev/null |   grep 'Started'" &amp;gt; $TMP_PAGE2 &lt;BR /&gt;&lt;BR /&gt; echo "&lt;HR width="50%" /&gt;" &amp;gt;&amp;gt; $TMP_PAGE2&lt;BR /&gt; echo $END &amp;gt;&amp;gt; $TMP_PAGE2&lt;BR /&gt;&lt;BR /&gt;# Get the end time - will also use later for COLOR selection&lt;BR /&gt;&lt;BR /&gt; END=$(ssh $i "tail -2 /var/opt/ignite/logs/makrec.log1 2&amp;gt; /dev/null |  &lt;BR /&gt;  grep '^Ended'") &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; echo "&lt;BR /&gt;" &amp;gt;&amp;gt; $TMP_PAGE2&lt;BR /&gt; echo "" &amp;gt;&amp;gt; $TMP_PAGE2&lt;BR /&gt;&lt;BR /&gt;# Get the failure code and set the color&lt;BR /&gt;&lt;BR /&gt;FAIL_CODE=$(ssh $i "tail -1 /var/opt/ignite/logs/makrec.log1 2&amp;gt; /dev/null |       grep 'Ended' 'makrec.log1' |       tail -1")&lt;BR /&gt;&lt;BR /&gt; case $FAIL_CODE in &lt;BR /&gt;&lt;BR /&gt;  "Completed" )&lt;BR /&gt;   COLOR="GREEN"&lt;BR /&gt;  ;;&lt;BR /&gt;&lt;BR /&gt;  "Ended" )&lt;BR /&gt;   COLOR="RED"&lt;BR /&gt;  ;;&lt;BR /&gt;&lt;BR /&gt;  * )&lt;BR /&gt;   COLOR="RED"&lt;BR /&gt;  ;;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; esac&lt;BR /&gt;&lt;BR /&gt;# Also set the COLOR based on $END&lt;BR /&gt;&lt;BR /&gt; [ $(echo $END | grep -c Ended) -eq 1 ] &amp;amp;&amp;amp; COLOR="GREEN"&lt;BR /&gt;&lt;BR /&gt;# Build the first column - This is where we set the color&lt;BR /&gt;&lt;BR /&gt; echo "" &amp;gt; $TMP_PAGE1&lt;BR /&gt;&lt;BR /&gt;        echo "&lt;FONT size="+1" face="Arial"&gt;" &amp;gt;&amp;gt; $TMP_PAGE1&lt;BR /&gt; echo "$i &lt;/FONT&gt;" &amp;gt;&amp;gt; $TMP_PAGE1&lt;BR /&gt;        echo "&lt;FONT size="-1" face="Arial"&gt;" &amp;gt;&amp;gt; $TMP_PAGE1&lt;BR /&gt; echo "&lt;BR /&gt;" &amp;gt;&amp;gt; $TMP_PAGE1&lt;BR /&gt;&lt;BR /&gt;# Pull it together&lt;BR /&gt;&lt;BR /&gt;cat $TMP_PAGE1 $TMP_PAGE2 &amp;gt;&amp;gt; $PAGE&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;# end the table&lt;BR /&gt;&lt;BR /&gt;echo "" &amp;gt;&amp;gt; $PAGE&lt;BR /&gt;echo "" &amp;gt;&amp;gt; $PAGE&lt;BR /&gt;&lt;/FONT&gt;</description>
      <pubDate>Wed, 03 Oct 2001 17:40:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589309#M880140</guid>
      <dc:creator>Ragni Singh</dc:creator>
      <dc:date>2001-10-03T17:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: script question here</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589310#M880141</link>
      <description>Sanman,&lt;BR /&gt;&lt;BR /&gt;Check the line&lt;BR /&gt;&lt;BR /&gt;FAIL_CODE=$(ssh $i "tail -1 /var/opt/ignite/logs/makrec.log1 2&amp;gt; /dev/null | grep 'Ended' 'makrec.log1' | tail -1") &lt;BR /&gt;&lt;BR /&gt;Also, 'makrec.log1' in the above should give you an error that makrec.log1 not found.&lt;BR /&gt;&lt;BR /&gt;tail -1 gives you ****** . You may need to make it tail -2.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 03 Oct 2001 18:11:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589310#M880141</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-10-03T18:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: script question here</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589311#M880142</link>
      <description>Thanks but that didn't help. What I want the script to do is if it was sucessful, I would get a green columm and if it was uncessful, I would get a red columm. Hope this helps.</description>
      <pubDate>Wed, 03 Oct 2001 18:18:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589311#M880142</guid>
      <dc:creator>Ragni Singh</dc:creator>
      <dc:date>2001-10-03T18:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: script question here</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589312#M880143</link>
      <description>Sanman,&lt;BR /&gt;&lt;BR /&gt;Try this.&lt;BR /&gt;&lt;BR /&gt;remsh $i "tail -10 /var/opt/ignite/logs/makrec.log1 2&amp;gt; /dev/null | grep 'Started&lt;BR /&gt;'" &amp;gt; $TMP_PAGE2                                                                 &lt;BR /&gt;                                                                                &lt;BR /&gt;echo "&lt;HR width="50%" /&gt;" &amp;gt;&amp;gt; $TMP_PAGE2                                             &lt;BR /&gt;echo $END &amp;gt;&amp;gt; $TMP_PAGE2                                                         &lt;BR /&gt;                                                                                &lt;BR /&gt;# Get the end time - will also use later for COLOR selection                    &lt;BR /&gt;                                                                                &lt;BR /&gt;LINE=`remsh $i tail -2 /var/opt/ignite/logs/makrec.log1|head -1`                &lt;BR /&gt;DATE=`echo $LINE |awk '{FS="-";print $2}'`                                      &lt;BR /&gt;FAIL_CODE=`echo $LINE |awk '{FS="-";print $1}'`                                 &lt;BR /&gt;                                                                                &lt;BR /&gt;case $FAIL_CODE in                                                              &lt;BR /&gt;                                                                                &lt;BR /&gt;"Completed " )                                                                  &lt;BR /&gt;COLOR="GREEN"                                                                   &lt;BR /&gt;;;                                                                              &lt;BR /&gt;                                                                                &lt;BR /&gt;"Ended " )                                                                      &lt;BR /&gt;COLOR="RED"                                                                     &lt;BR /&gt;;;                                             &lt;BR /&gt;&lt;BR /&gt;* )                                                                          &lt;BR /&gt;COLOR="RED"                                                                  &lt;BR /&gt;;;                                                                           &lt;BR /&gt;                                                                             &lt;BR /&gt;esac                                                                         &lt;BR /&gt;                                                                             &lt;BR /&gt;                                                                             &lt;BR /&gt;# Build the first column - This is where we set the color                    &lt;BR /&gt;                                                                             &lt;BR /&gt;echo "" &amp;gt; $TMP_PAGE1                               &lt;BR /&gt;                                                                             &lt;BR /&gt;echo "&lt;FONT size="+1" face="Arial"&gt;" &amp;gt;&amp;gt; $TMP_PAGE1                             &lt;BR /&gt;echo "$i &lt;/FONT&gt;" &amp;gt;&amp;gt; $TMP_PAGE1                                                 &lt;BR /&gt;echo "&lt;FONT size="-1" face="Arial"&gt;" &amp;gt;&amp;gt; $TMP_PAGE1                             &lt;BR /&gt;echo "&lt;BR /&gt;" &amp;gt;&amp;gt; $TMP_PAGE1                                                    &lt;BR /&gt;                                                                             &lt;BR /&gt;# Pull it together                                                           &lt;BR /&gt;                                                                             &lt;BR /&gt;cat $TMP_PAGE1 $TMP_PAGE2 &amp;gt;&amp;gt; $PAGE                                          &lt;BR /&gt;&lt;BR /&gt;# end the table              &lt;BR /&gt;                             &lt;BR /&gt;echo "" &amp;gt;&amp;gt; $PAGE     &lt;BR /&gt;echo "" &amp;gt;&amp;gt; $PAGE      &lt;BR /&gt;                             &lt;BR /&gt;rm $TMP_PAGE1 $TMP_PAGE2     &lt;BR /&gt;                             &lt;BR /&gt;                                                                              &lt;BR /&gt;&lt;BR /&gt;                                                                                &lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;</description>
      <pubDate>Wed, 03 Oct 2001 18:45:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589312#M880143</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-10-03T18:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: script question here</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589313#M880144</link>
      <description>The test for FAIL_CODE in the case statement is asking for an exact match for the words Ended and Completed.  If the line contains any other text (and grep will return everything on the line), the test will drop to *) and make the color RED.&lt;BR /&gt;&lt;BR /&gt;It would be better to simply ask grep how many matches it found:&lt;BR /&gt;&lt;BR /&gt;... grep -c Completed ...&lt;BR /&gt;&lt;BR /&gt;if [ $FAIL_CODE -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;COLOR=RED&lt;BR /&gt;else&lt;BR /&gt;COLOR=GREEN&lt;BR /&gt;fi</description>
      <pubDate>Wed, 03 Oct 2001 18:50:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589313#M880144</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2001-10-03T18:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: script question here</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589314#M880145</link>
      <description>Oops.. You need to replace "remsh" with "ssh".&lt;BR /&gt;Also, I assigned DATE but not used it anywhere. You can use it somewhere in your table.&lt;BR /&gt;&lt;BR /&gt;Also, I didn't understand why you were grepping "Started" in the first sentence. So, I included it as it is..&lt;BR /&gt;&lt;BR /&gt;But if your intention is to find the Starting time, there would be multiple such entries. You can do it like this.&lt;BR /&gt;&lt;BR /&gt;ssh $i cat /var/opt/ignite/logs/makerec.log1|grep 'Started' |tail -1 &amp;gt; $TMP_PAGE2&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 03 Oct 2001 18:51:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589314#M880145</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-10-03T18:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: script question here</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589315#M880146</link>
      <description>Sorry guys, didn't mean to ignore anyone.</description>
      <pubDate>Wed, 23 Jan 2002 22:45:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question-here/m-p/2589315#M880146</guid>
      <dc:creator>Ragni Singh</dc:creator>
      <dc:date>2002-01-23T22:45:10Z</dc:date>
    </item>
  </channel>
</rss>

