<?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: Return Codes -Shell Scripts -HP-UX in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/return-codes-shell-scripts-hp-ux/m-p/2424511#M767232</link>
    <description>I have managed to resolve my own problem with a little help from Unix books and peers where I work.  For anyone else who may run into this, one solution is call a shell script from within an if statement rather than just calling it.   For eg: &lt;BR /&gt;&lt;BR /&gt;if  seq_check.scrpt seff50 seff50.dat&lt;BR /&gt;then&lt;BR /&gt;   echo "seq check was successful."       else&lt;BR /&gt;  echo "sequence check Failed!"&lt;BR /&gt;fi&lt;BR /&gt;</description>
    <pubDate>Mon, 05 Jun 2000 14:19:26 GMT</pubDate>
    <dc:creator>Vince Idone</dc:creator>
    <dc:date>2000-06-05T14:19:26Z</dc:date>
    <item>
      <title>Return Codes -Shell Scripts -HP-UX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/return-codes-shell-scripts-hp-ux/m-p/2424507#M767228</link>
      <description>I'm using HP-UX ver. B.10.20 E 9000/889&lt;BR /&gt;&lt;BR /&gt;Has anyone run across this?  I have a scriptA&lt;BR /&gt;which calls scriptB.  If scriptB returns a status code of 0, no problem, execution continues with subsequent statements in scriptA.&lt;BR /&gt;&lt;BR /&gt;However, if scriptB returns abnormal termination (anything other than zero, eg even exiting with "exit 1"), everything stops, subsequent statements in scriptB are &lt;BR /&gt;not executed. &lt;BR /&gt;&lt;BR /&gt;What I want to do in scriptA is to check the&lt;BR /&gt;status code returned, and execute appropriate&lt;BR /&gt;logic.  &lt;BR /&gt;&lt;BR /&gt;I'm wondering, does a profile parameter need to be changed? Shell problem?  HP-UX bug?&lt;BR /&gt;&lt;BR /&gt;Thanx in advance to whoever can help.  &lt;BR /&gt;Vince Idone</description>
      <pubDate>Thu, 01 Jun 2000 13:56:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/return-codes-shell-scripts-hp-ux/m-p/2424507#M767228</guid>
      <dc:creator>Vince Idone</dc:creator>
      <dc:date>2000-06-01T13:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Return Codes -Shell Scripts -HP-UX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/return-codes-shell-scripts-hp-ux/m-p/2424508#M767229</link>
      <description>How you do this is going to depend on how the script B works.&lt;BR /&gt;Basically, when B has finished, and returns control to A, you can check the return value from B, by doing a test on the value supplied by $?.&lt;BR /&gt;The problem is that you may want to have differing return values, and the best way to do this is to change script B to test at various stages, and depending on whether that stage has been succesfull, set the exit code to a value for that specific stage;&lt;BR /&gt;eg:&lt;BR /&gt;A calls B&lt;BR /&gt;B starts to run, does abc, test if ok, if yes continue, else exit 2&lt;BR /&gt;assming ok, next stage in B, test for correct result, ok then continue, or if not exit 3.&lt;BR /&gt;In A you would then have something like a case statement that tests $?, and does:&lt;BR /&gt;&lt;BR /&gt;value 2) means erro x&lt;BR /&gt;value 3) means error y &lt;BR /&gt;and so on.&lt;BR /&gt;&lt;BR /&gt;I hope this helps.</description>
      <pubDate>Thu, 01 Jun 2000 14:11:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/return-codes-shell-scripts-hp-ux/m-p/2424508#M767229</guid>
      <dc:creator>melvyn burnard</dc:creator>
      <dc:date>2000-06-01T14:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: Return Codes -Shell Scripts -HP-UX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/return-codes-shell-scripts-hp-ux/m-p/2424509#M767230</link>
      <description>This behavior results from setting the -e option when the shell is invoked.  All shells have a -e option and most also allow you to do a "set -e" to turn on this benavior during execution.  So you must be doing a &lt;BR /&gt;&lt;BR /&gt;set -e &lt;BR /&gt;&lt;BR /&gt;somewhere or you invoked the shell like:&lt;BR /&gt;&lt;BR /&gt;#! /usr/bin/ksh -e</description>
      <pubDate>Thu, 01 Jun 2000 14:23:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/return-codes-shell-scripts-hp-ux/m-p/2424509#M767230</guid>
      <dc:creator>Paul Hite</dc:creator>
      <dc:date>2000-06-01T14:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: Return Codes -Shell Scripts -HP-UX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/return-codes-shell-scripts-hp-ux/m-p/2424510#M767231</link>
      <description>Dummy idea: aren't you sourcing sciptB?&lt;BR /&gt;&lt;BR /&gt;I got following problem a couple of days ago: scriptA sources scriptB (scriptA contains a line such as . scriptB). In scriptB if an error is detected, I used "exit 1" statements. &lt;BR /&gt;&lt;BR /&gt;Bad idea, since "exit" ends the current process... and sourcing a script uses the SAME process for BOTH scripts, thus scriptB stops scriptA. (More funny: if you source scriptB from a remote session, it even closes the remote session!)&lt;BR /&gt;&lt;BR /&gt;Since I replaced all "exit" statements by "return" statements, everything runs fine.&lt;BR /&gt;&lt;BR /&gt;Hope it helps,&lt;BR /&gt;Emmanuel</description>
      <pubDate>Mon, 05 Jun 2000 08:40:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/return-codes-shell-scripts-hp-ux/m-p/2424510#M767231</guid>
      <dc:creator>Emmanuel Eyer</dc:creator>
      <dc:date>2000-06-05T08:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Return Codes -Shell Scripts -HP-UX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/return-codes-shell-scripts-hp-ux/m-p/2424511#M767232</link>
      <description>I have managed to resolve my own problem with a little help from Unix books and peers where I work.  For anyone else who may run into this, one solution is call a shell script from within an if statement rather than just calling it.   For eg: &lt;BR /&gt;&lt;BR /&gt;if  seq_check.scrpt seff50 seff50.dat&lt;BR /&gt;then&lt;BR /&gt;   echo "seq check was successful."       else&lt;BR /&gt;  echo "sequence check Failed!"&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Jun 2000 14:19:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/return-codes-shell-scripts-hp-ux/m-p/2424511#M767232</guid>
      <dc:creator>Vince Idone</dc:creator>
      <dc:date>2000-06-05T14:19:26Z</dc:date>
    </item>
  </channel>
</rss>

