<?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: Exit Script on failure? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568336#M227771</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Could not open the attachment. Please reattach.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Devender</description>
    <pubDate>Wed, 22 Jun 2005 05:42:51 GMT</pubDate>
    <dc:creator>Devender Khatana</dc:creator>
    <dc:date>2005-06-22T05:42:51Z</dc:date>
    <item>
      <title>Exit Script on failure?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568333#M227768</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have written sub script that sends (rcp's) a certain type of file to another server. If by any chance the line drops however this file will be put into an archive dir resulting in the file not being sent. Can anyone tell me how I can incorporate a err/exit code into my script so that if the rcp fails then the entire script will exit at that point peventing the file being archived and ensuring that it will get rcp'ed the next time it is run from the cron. &lt;BR /&gt;&lt;BR /&gt;Dermot</description>
      <pubDate>Wed, 22 Jun 2005 05:31:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568333#M227768</guid>
      <dc:creator>Duffs</dc:creator>
      <dc:date>2005-06-22T05:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Exit Script on failure?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568334#M227769</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Can you attach the script &amp;amp; the cron entry which is doing this?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Devender</description>
      <pubDate>Wed, 22 Jun 2005 05:33:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568334#M227769</guid>
      <dc:creator>Devender Khatana</dc:creator>
      <dc:date>2005-06-22T05:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Exit Script on failure?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568335#M227770</link>
      <description>Please find the attached script.&lt;BR /&gt;&lt;BR /&gt;This sub script is called as part of a larger script that is kicked off the cron every 5 mins.</description>
      <pubDate>Wed, 22 Jun 2005 05:39:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568335#M227770</guid>
      <dc:creator>Duffs</dc:creator>
      <dc:date>2005-06-22T05:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: Exit Script on failure?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568336#M227771</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Could not open the attachment. Please reattach.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Devender</description>
      <pubDate>Wed, 22 Jun 2005 05:42:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568336#M227771</guid>
      <dc:creator>Devender Khatana</dc:creator>
      <dc:date>2005-06-22T05:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: Exit Script on failure?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568337#M227772</link>
      <description>Hi Dermot,&lt;BR /&gt;This should work :&lt;BR /&gt;&lt;BR /&gt;.....&lt;BR /&gt;rcp ....&lt;BR /&gt;var1=`echo $?`&lt;BR /&gt;if [ $var1 -ne 0 ]&lt;BR /&gt;then&lt;BR /&gt;  exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 22 Jun 2005 05:44:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568337#M227772</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2005-06-22T05:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Exit Script on failure?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568338#M227773</link>
      <description>You can get return value from rcp command after it's execution as,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;rcp &lt;SERVERA&gt;:/tmp/test/*.sh /tmp/test/&lt;BR /&gt;if [[ $? -eq 0 ]]&lt;BR /&gt;then&lt;BR /&gt; echo "success"&lt;BR /&gt; ...action..&lt;BR /&gt;else&lt;BR /&gt; echo "failure"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;hth.&lt;BR /&gt;&lt;/SERVERA&gt;</description>
      <pubDate>Wed, 22 Jun 2005 05:47:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568338#M227773</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-06-22T05:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Exit Script on failure?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568339#M227774</link>
      <description>These error messages only apply to the sub-script, they don't actually transfer to the main script therefore the program doesn't actually exit but continues excuting the remaining sub scripts instead of bombing out.&lt;BR /&gt;&lt;BR /&gt;I really need to know how to transfer an error message from one script (this sub script) to another script (my main script).&lt;BR /&gt;&lt;BR /&gt;Dermot</description>
      <pubDate>Wed, 22 Jun 2005 06:15:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568339#M227774</guid>
      <dc:creator>Duffs</dc:creator>
      <dc:date>2005-06-22T06:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Exit Script on failure?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568340#M227775</link>
      <description>I have read your script but with un-need codes more there.&lt;BR /&gt;&lt;BR /&gt; #!/bin/ksh&lt;BR /&gt; # subscript.ksh&lt;BR /&gt; rcp &lt;FILES&gt; server2:&lt;LOCATION&gt;&lt;BR /&gt; if [[ $? -eq 0 ]]&lt;BR /&gt; then&lt;BR /&gt;    echo "Success"&lt;BR /&gt; else&lt;BR /&gt;   echo "failure"&lt;BR /&gt;  exit 1&lt;BR /&gt; fi&lt;BR /&gt;&lt;BR /&gt; exit 0&lt;BR /&gt;&lt;BR /&gt;######################&lt;BR /&gt; &lt;BR /&gt; #!/bin/ksh&lt;BR /&gt; #main.ksh&lt;BR /&gt; sh subscript.sh&lt;BR /&gt; if [[ $? -eq 0 ]]&lt;BR /&gt; then&lt;BR /&gt;   echo "Subscript is successful"&lt;BR /&gt; else&lt;BR /&gt;   echo "Subscript is failed"&lt;BR /&gt;   exit 1&lt;BR /&gt; fi&lt;BR /&gt; exit 0&lt;BR /&gt;hth.&lt;/LOCATION&gt;&lt;/FILES&gt;</description>
      <pubDate>Wed, 22 Jun 2005 06:32:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568340#M227775</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-06-22T06:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Exit Script on failure?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568341#M227776</link>
      <description>You can also use global log file to log subscript informations.&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;#subscript.ksh&lt;BR /&gt;LOGFILE=/tmp/subscript.log&lt;BR /&gt;rcp ..&lt;BR /&gt;if [[ $? -eq 0 ]]&lt;BR /&gt;then&lt;BR /&gt;  echo "success" &amp;gt; $LOGFILE&lt;BR /&gt;else&lt;BR /&gt;  echo "failed" &amp;gt; $LOGFILE&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;## Main script ###&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;#main.ksh&lt;BR /&gt;LOGFILE=/tmp/subscript.log&lt;BR /&gt;ksh subscript.ksh&lt;BR /&gt;if [[ -f $LOGFILE ]]&lt;BR /&gt;then&lt;BR /&gt;  grep -q success $LOGFILE&lt;BR /&gt;  if [[ $? -eq 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Subscript execution is success"&lt;BR /&gt;  else&lt;BR /&gt;    echo " ...failed"&lt;BR /&gt;  fi&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;hth.&lt;BR /&gt;</description>
      <pubDate>Wed, 22 Jun 2005 06:36:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568341#M227776</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-06-22T06:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Exit Script on failure?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568342#M227777</link>
      <description>Thanks a million, that did the trick, much appreciated!&lt;BR /&gt;&lt;BR /&gt;Kind Regards,&lt;BR /&gt;Dermot</description>
      <pubDate>Wed, 22 Jun 2005 06:46:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568342#M227777</guid>
      <dc:creator>Duffs</dc:creator>
      <dc:date>2005-06-22T06:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Exit Script on failure?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568343#M227778</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;As it turns out the above solution is only half the solution as it does not completely solve my problem. In the instance where there are no files to rcp, the script returns an error value of 1 thus bombing out instead of returning value zero and continuing to the next sub script.&lt;BR /&gt;&lt;BR /&gt;Is there a way I can catalog the dir, i.e. run a 'ls' or 'read' on the dir and if there are no files present simply return a 0 and continue with the remainder of the script instead of exiting?&lt;BR /&gt;&lt;BR /&gt;Dermot</description>
      <pubDate>Wed, 22 Jun 2005 09:51:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-script-on-failure/m-p/3568343#M227778</guid>
      <dc:creator>Duffs</dc:creator>
      <dc:date>2005-06-22T09:51:29Z</dc:date>
    </item>
  </channel>
</rss>

