<?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: Shell scripting in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/3091921#M145019</link>
    <description>standard error trapping script logic.&lt;BR /&gt;&lt;BR /&gt;/usr/openv/netbackup/backupscript&lt;BR /&gt;rc=$?&lt;BR /&gt;&lt;BR /&gt;if [ $rc -eq 134 ] then&lt;BR /&gt;# take action based on code 134 email whatever&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;# action&lt;BR /&gt;if [ $rc -eq 0 ] then&lt;BR /&gt;# take action based on code 134 email &lt;BR /&gt;sample.sh &lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;A little more elegant:&lt;BR /&gt;&lt;BR /&gt;if [ $rc -nq 0 ] then&lt;BR /&gt;# action perhaps check the code and act.&lt;BR /&gt;else&lt;BR /&gt;# &lt;BR /&gt;sample.sh&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thats how you trap and act on error codes.&lt;BR /&gt; &lt;BR /&gt;I see no reason to make it really complex.&lt;BR /&gt; &lt;BR /&gt;SEP</description>
    <pubDate>Mon, 13 Oct 2003 11:07:03 GMT</pubDate>
    <dc:creator>Steven E. Protter</dc:creator>
    <dc:date>2003-10-13T11:07:03Z</dc:date>
    <item>
      <title>Shell scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/3091920#M145018</link>
      <description>Experts,&lt;BR /&gt;I dont know whether this is the right place i should put this RFH (Request For Help). I am executing a netbackup command which can throw three different error codes a 0,1 and 134. I have to handle these error codes in different manner. Let me put down the process how everything goes.&lt;BR /&gt;&lt;BR /&gt;step -1 : script executes putting a flag called "backupstart" with time in a &lt;BR /&gt;text file..&lt;BR /&gt;&lt;BR /&gt;Step-2: Execute the backup...list of file systems should be taken from another text file as input. basically we should be able to edit the text file at will for whatever file system we want to backup.&lt;BR /&gt;&lt;BR /&gt;Step-3: Needs to be pretty smart in finding the exit code of step-3 and take corrective action&lt;BR /&gt;&lt;BR /&gt;Following are the corrective actions&lt;BR /&gt;&lt;BR /&gt;If ( "backupstart" flag exists &amp;amp;&amp;amp; exit code == 134 ) Do nothing&lt;BR /&gt;&lt;BR /&gt;else if ("backupstart" flag exists &amp;amp;&amp;amp; exit code == 0) execute another script sample.sh &lt;BR /&gt;and remove the "backupstart" flag&lt;BR /&gt;&lt;BR /&gt;else if (status == 1 &amp;amp;&amp;amp; backupstart flag exists) e-mail/page support staff "someemail.email.com"&lt;BR /&gt;&lt;BR /&gt;Experts first i dont know how to put a flag before starting the execution of the script as said in step-1. &lt;BR /&gt;I have the script for step-2. I dont know how to work handle the error codes for the and do something after that in Step-3. &lt;BR /&gt;&lt;BR /&gt;I am attaching the script i have for step-2. If you can help me in getting step-1 and step-3 i would be grateful to you.</description>
      <pubDate>Mon, 13 Oct 2003 10:50:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/3091920#M145018</guid>
      <dc:creator>ramesh_6</dc:creator>
      <dc:date>2003-10-13T10:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: Shell scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/3091921#M145019</link>
      <description>standard error trapping script logic.&lt;BR /&gt;&lt;BR /&gt;/usr/openv/netbackup/backupscript&lt;BR /&gt;rc=$?&lt;BR /&gt;&lt;BR /&gt;if [ $rc -eq 134 ] then&lt;BR /&gt;# take action based on code 134 email whatever&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;# action&lt;BR /&gt;if [ $rc -eq 0 ] then&lt;BR /&gt;# take action based on code 134 email &lt;BR /&gt;sample.sh &lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;A little more elegant:&lt;BR /&gt;&lt;BR /&gt;if [ $rc -nq 0 ] then&lt;BR /&gt;# action perhaps check the code and act.&lt;BR /&gt;else&lt;BR /&gt;# &lt;BR /&gt;sample.sh&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thats how you trap and act on error codes.&lt;BR /&gt; &lt;BR /&gt;I see no reason to make it really complex.&lt;BR /&gt; &lt;BR /&gt;SEP</description>
      <pubDate>Mon, 13 Oct 2003 11:07:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/3091921#M145019</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2003-10-13T11:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: Shell scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/3091922#M145020</link>
      <description>Ramesh -&lt;BR /&gt;Below is a cut and paste from one of our netbackup scripts. It is pretty much what you are asking though our return code searches are different. Hope the lines "line up" on the paste to the reply.&lt;BR /&gt;&lt;BR /&gt;Best of Luck.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;dl&lt;BR /&gt;&lt;BR /&gt;# =================================================================================================&lt;BR /&gt;# Start the backup process.&lt;BR /&gt;# Create a touch file for verification of completed backup if successful.&lt;BR /&gt;# =================================================================================================&lt;BR /&gt;        date &amp;gt; $ERROR_LOG1&lt;BR /&gt;        $veritas_path/bpbackup -w -c $CLASS -s $SCHED -f $FILE_LIST_1&lt;BR /&gt;        status=$?&lt;BR /&gt;        if [ "$status" -eq 0 ]&lt;BR /&gt;        then&lt;BR /&gt;        echo "Backup results for $CLASS $FILE_LIST_1 return code $status" &amp;gt;&amp;gt; $RESULTS_FILE&lt;BR /&gt;        touch $COMPLETED_FILE1&lt;BR /&gt;# =================================================================================================&lt;BR /&gt;# Call the call_umount script if all backups finished successfully.&lt;BR /&gt;# =================================================================================================&lt;BR /&gt;&lt;BR /&gt;        $CALL_UMOUNT&lt;BR /&gt;        exit 0&lt;BR /&gt;        fi&lt;BR /&gt;&lt;BR /&gt;        while [ "$status" -gt 0 ]&lt;BR /&gt;        do&lt;BR /&gt;        if [ "$status" -eq 84 -a "$count" -eq 0 ]&lt;BR /&gt;        then&lt;BR /&gt;        echo "Backup results for $CLASS $FILE_LIST_1 return code $status" &amp;gt;&amp;gt; $RESULTS_FILE&lt;BR /&gt;        echo "Restarting this job at `date`" &amp;gt;&amp;gt; $RESULTS_FILE&lt;BR /&gt;        $veritas_path/bpbackup -w -c $CLASS -s $SCHED -f $FILE_LIST_1&lt;BR /&gt;        status=$?&lt;BR /&gt;        let count="$count + 1"&lt;BR /&gt;        elif [ "$status" -ne 84 -a "$status" -ne 0 ]&lt;BR /&gt;        then&lt;BR /&gt;        echo "Errors on backup for $CLASS return code $status" &amp;gt;&amp;gt; $ERROR_LOG1&lt;BR /&gt;        echo "Contact Ron or Dave." &amp;gt;&amp;gt; $ERROR_LOG1&lt;BR /&gt;        echo "Process affected is jdaprod backup." &amp;gt;&amp;gt; $ERROR_LOG1&lt;BR /&gt;        echo "No completed flag will be created; umount will not occur." &amp;gt;&amp;gt; $ERROR_LOG1&lt;BR /&gt;        $mail_path/mailx -s "Errors on backup of $CLASS Directory" $MAIL_LIST &amp;lt; $ERROR_LOG1&lt;BR /&gt;        $VSE_NOTIFY&lt;BR /&gt;        exit;&lt;BR /&gt;        elif [ "$count" -eq 1 -a "status" -ne 0 ]&lt;BR /&gt;        then&lt;BR /&gt;        echo "Errors on backup for $CLASS return code $status" &amp;gt;&amp;gt; $ERROR_LOG1&lt;BR /&gt;        echo "Contact Ron or Dave." &amp;gt;&amp;gt; $ERROR_LOG1&lt;BR /&gt;        echo "Process affected is jdaprod backup." &amp;gt;&amp;gt; $ERROR_LOG1&lt;BR /&gt;        echo "No completed flag will be created; umount will not occur." &amp;gt;&amp;gt; $ERROR_LOG1&lt;BR /&gt;        $mail_path/mailx -s "Errors on backup of $CLASS Directory" $MAIL_LIST &amp;lt; $ERROR_LOG1&lt;BR /&gt;        $VSE_NOTIFY&lt;BR /&gt;        exit;&lt;BR /&gt;        fi&lt;BR /&gt;        done&lt;BR /&gt;</description>
      <pubDate>Mon, 13 Oct 2003 13:02:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/3091922#M145020</guid>
      <dc:creator>Dave La Mar</dc:creator>
      <dc:date>2003-10-13T13:02:01Z</dc:date>
    </item>
  </channel>
</rss>

