<?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 help please. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2907252#M106331</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I've worked in a similar case but ussing a custom script file, my logic have been the following:&lt;BR /&gt;&lt;BR /&gt;fbackup -0 -v -i / -e /tmp -f /dev/rmt/0m 2&amp;gt; /tmp/fbackup.log&lt;BR /&gt;STATUS=$?&lt;BR /&gt;case in $STATUS&lt;BR /&gt;  0) Your successful procedure&lt;BR /&gt;  ;;&lt;BR /&gt;  4) Your warning procedure&lt;BR /&gt;  ;;&lt;BR /&gt;  *) Your fail procedure&lt;BR /&gt;  ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;The main advantage of redirect the log file (/tmp/fbackup.log), is that you can manipulate it to extract the warning messages and send them in the case of a status 4.&lt;BR /&gt;&lt;BR /&gt;Rgds.</description>
    <pubDate>Tue, 18 Feb 2003 19:17:49 GMT</pubDate>
    <dc:creator>Jose Mosquera</dc:creator>
    <dc:date>2003-02-18T19:17:49Z</dc:date>
    <item>
      <title>script help please.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2907249#M106328</link>
      <description>Hi all, In a delimma and need some serious help from a script guru. I have this script here that looks at the br_log file for sucess and failed backup messages. If the backup fails, It will higlight the columm read and if the backup was sucessful, It would display a green columm. Attached it my script and the ouput that I am hoping for it to display. Thanks for all your time and I will forever be greatful for your time. &lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;##################################################################&lt;BR /&gt;&lt;BR /&gt;# Declare variables&lt;BR /&gt;PATH=/usr/bin:/usr/local/bin&lt;BR /&gt;SERVERS="/home/xxx/xxxxx"&lt;BR /&gt;PAGE="/opt/apache/htdocs/testing/testing-$(date +%m-%d-%Y).html"&lt;BR /&gt;TODAY="/opt/apache/htdocs/testing/testing.html"&lt;BR /&gt;TMP_PAGE1="/tmp/testing1.html"&lt;BR /&gt;TMP_PAGE2="/tmp/testing2.html"&lt;BR /&gt;DATE=$(date)&lt;BR /&gt;COLOR=""&lt;BR /&gt;FAIL_CODE=""&lt;BR /&gt;END=""&lt;BR /&gt;&lt;BR /&gt;# Make sure we start clean&lt;BR /&gt;/usr/bin/rm -f $TMP_PAGE1 $TMP_PAGE2 $TODAY&lt;BR /&gt;&lt;BR /&gt;# Start the page&lt;BR /&gt;&lt;BR /&gt;cat &amp;lt;&amp;lt;-EOF &amp;gt; $PAGE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TITLE&gt; Backup completions &lt;/TITLE&gt;&lt;BR /&gt;&lt;FONT size="+1" face="Arial"&gt;&lt;BR /&gt;&lt;P&gt;&lt;BR /&gt;Last updated: $DATE&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT size="+0" face="Arial"&gt;&lt;BR /&gt;NOTES:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="+0" face="Arial"&gt;&lt;BR /&gt;Please notify Engineering if any backup fails.&lt;BR /&gt;&lt;FONT size="+0" face="Arial"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;# Start the table&lt;BR /&gt;&lt;BR /&gt;cat &amp;lt;&amp;lt;-EOF &amp;gt;&amp;gt; $PAGE&lt;BR /&gt;        &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;        &lt;TABLE vspace="1" border=""&gt;&lt;BR /&gt;        &lt;FONT size="+0" face="Arial"&gt;&lt;BR /&gt;        &lt;TBODY&gt;&lt;TR&gt; &lt;TH align="left"&gt;&lt;/TH&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;# Get the data&lt;BR /&gt;&lt;BR /&gt;for i in `cat $SERVERS`&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;# Get the start time&lt;BR /&gt;&lt;BR /&gt;        ssh $i "grep -i "Starting" /var/sam/log/br_log 2&amp;gt; /dev/null |                 tail -1" &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;&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/sam/log/br_log 2&amp;gt; /dev/null |                 grep -v -e 'Starting'")&lt;BR /&gt;&lt;BR /&gt;        echo $END &amp;gt;&amp;gt; $TMP_PAGE2&lt;BR /&gt;&lt;BR /&gt;        echo "&lt;BR /&gt;" &amp;gt;&amp;gt; $TMP_PAGE2&lt;BR /&gt;        echo "&lt;/TD&gt;&lt;TD&gt;" &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 -2 /var/sam/log/br_log 2&amp;gt; /dev/null |                     grep -i 'Completed' | 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;                "ERROR" )&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;        esac&lt;BR /&gt;&lt;BR /&gt;# Also set the COLOR based on $END&lt;BR /&gt;&lt;BR /&gt;        [ $(echo $END | grep -c ERROR) -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 "&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD bgcolor="${COLOR}"&gt;" &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;&lt;/TD&gt;&lt;TD&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 "&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/FONT&gt;&lt;/TABLE&gt;" &amp;gt;&amp;gt; $PAGE&lt;BR /&gt;echo "" &amp;gt;&amp;gt; $PAGE&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;Here is the log output from 2 systems.&lt;BR /&gt;01/30/03 02:01:05&lt;BR /&gt;01/30/03 02:01:05   Starting non-root full backup ...&lt;BR /&gt;01/30/03 03:25:18   Full Backup was successful&lt;BR /&gt;01/30/03 03:25:18   Full Backup Completed.&lt;BR /&gt;##################################################&lt;BR /&gt;# EXITING with 0 return code....                 #&lt;BR /&gt;##################################################&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;systems2&lt;BR /&gt;&lt;BR /&gt;01/28/03 12:00:34&lt;BR /&gt;01/28/03 12:00:34   Starting non-root full backup ...&lt;BR /&gt;01/28/03 12:01:17   ERROR: Full Backup FAILED !!! Contact System Admin&lt;BR /&gt;01/28/03 12:01:17   Exit with error !!!&lt;BR /&gt;&lt;BR /&gt;##################################################&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;system1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/FONT&gt;</description>
      <pubDate>Tue, 18 Feb 2003 17:18:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2907249#M106328</guid>
      <dc:creator>Ragni Singh</dc:creator>
      <dc:date>2003-02-18T17:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: script help please.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2907250#M106329</link>
      <description>FAIL_CODE=$(ssh $i "tail -2 /var/sam/log/br_log 2&amp;gt; /dev/null | grep -i 'Completed' | tail -1")&lt;BR /&gt;...&lt;BR /&gt;esace&lt;BR /&gt;&lt;BR /&gt;I think is your problem...&lt;BR /&gt;&lt;BR /&gt;Change to-&lt;BR /&gt;if $(ssh $i "tail -2 /var/sam/log/br_log 2&amp;gt; /dev/null | grep -q -i 'Completed'") ; then&lt;BR /&gt; COLOR="GREEN"&lt;BR /&gt;else&lt;BR /&gt; COLOR="RED"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;The if will test the status of the last command (grep in this case) and if Completed is found, then set COLOR to GREEN.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Feb 2003 17:49:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2907250#M106329</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-02-18T17:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: script help please.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2907251#M106330</link>
      <description>Hi Sanjay,&lt;BR /&gt;&lt;BR /&gt;Since there is no fixed field for the STATUS, you may want to use this code. You can extend the if statement further if you have other STATUS values in addition to "successful" and "FAILED".&lt;BR /&gt;&lt;BR /&gt;Take out the case statement and replace it with the following&lt;BR /&gt;....&lt;BR /&gt;ssh $i "tail -2 /var/sam/log/br_log " |grep "successful" &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;COLOR="GREEN"&lt;BR /&gt;else&lt;BR /&gt;COLOR="RED&lt;BR /&gt;fi&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Tue, 18 Feb 2003 19:13:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2907251#M106330</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2003-02-18T19:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: script help please.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2907252#M106331</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I've worked in a similar case but ussing a custom script file, my logic have been the following:&lt;BR /&gt;&lt;BR /&gt;fbackup -0 -v -i / -e /tmp -f /dev/rmt/0m 2&amp;gt; /tmp/fbackup.log&lt;BR /&gt;STATUS=$?&lt;BR /&gt;case in $STATUS&lt;BR /&gt;  0) Your successful procedure&lt;BR /&gt;  ;;&lt;BR /&gt;  4) Your warning procedure&lt;BR /&gt;  ;;&lt;BR /&gt;  *) Your fail procedure&lt;BR /&gt;  ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;The main advantage of redirect the log file (/tmp/fbackup.log), is that you can manipulate it to extract the warning messages and send them in the case of a status 4.&lt;BR /&gt;&lt;BR /&gt;Rgds.</description>
      <pubDate>Tue, 18 Feb 2003 19:17:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2907252#M106331</guid>
      <dc:creator>Jose Mosquera</dc:creator>
      <dc:date>2003-02-18T19:17:49Z</dc:date>
    </item>
  </channel>
</rss>

