<?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 on a script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557841#M887589</link>
    <description>Hi Bill:&lt;BR /&gt;&lt;BR /&gt;I can't resist saying "AMEN!".  The notation of "end &lt;SOMETHING&gt;" is so desirable...on reports, in code...  At least in languages like ALGOL and PASCAL we have the enforced "END" to delineate the outer block! ;-)&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/SOMETHING&gt;</description>
    <pubDate>Fri, 27 Jul 2001 12:43:55 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2001-07-27T12:43:55Z</dc:date>
    <item>
      <title>exit on a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557833#M887581</link>
      <description>When and why and should you type exit at the end of a script ?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Richard</description>
      <pubDate>Fri, 27 Jul 2001 06:19:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557833#M887581</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2001-07-27T06:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: exit on a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557834#M887582</link>
      <description>passing a parameter with exit (exit 2  i.e.) you can check the exit starus from your script. useful if you want to check wheter your script dit an normal exit or aborted on an error condition .&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Jul 2001 06:26:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557834#M887582</guid>
      <dc:creator>Rainer von Bongartz</dc:creator>
      <dc:date>2001-07-27T06:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: exit on a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557835#M887583</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;after executing the script exit(1) just comes back to prompt without closing the file, where as exit(2) closes the file and comes out</description>
      <pubDate>Fri, 27 Jul 2001 06:54:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557835#M887583</guid>
      <dc:creator>Ravi_8</dc:creator>
      <dc:date>2001-07-27T06:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: exit on a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557836#M887584</link>
      <description>so i should use exit(2) on every script?&lt;BR /&gt;&lt;BR /&gt;Richard</description>
      <pubDate>Fri, 27 Jul 2001 07:28:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557836#M887584</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2001-07-27T07:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: exit on a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557837#M887585</link>
      <description>Hi,&lt;BR /&gt;sorry for mistake, it's actually it is exit(0) and exit(1). yu can use exit(1) at the script end.</description>
      <pubDate>Fri, 27 Jul 2001 09:03:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557837#M887585</guid>
      <dc:creator>Ravi_8</dc:creator>
      <dc:date>2001-07-27T09:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: exit on a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557838#M887586</link>
      <description>Hi Richard:&lt;BR /&gt;&lt;BR /&gt;First, it is good practice to exit a script with a defined return value.  If you don't, the exit value will be the return value of the last command executed, by default.&lt;BR /&gt;&lt;BR /&gt;Standards define three exit values, the remainder being a user's choice:&lt;BR /&gt;&lt;BR /&gt;0 =&amp;gt; command or process completed successfully&lt;BR /&gt;1 =&amp;gt; command or process failed&lt;BR /&gt;2 =&amp;gt; command or process had warnings&lt;BR /&gt;&lt;BR /&gt;A good example of a command following these guidelines is 'grep'.  An example of a command that deviates is 'diff'.  Take a look at the man pages for both to see!&lt;BR /&gt;&lt;BR /&gt;Thus, even these guidelines are not hard-and-fast.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 27 Jul 2001 09:32:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557838#M887586</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-07-27T09:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: exit on a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557839#M887587</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;in most cases you don't really need an exit statement at the end of your script.  The shell process will terminate at the end of your script unless you have set "ignoreeof" option.&lt;BR /&gt;Exit is mostly used to exit from within your script at certain conditions: error, file not found, execute not required, .....&lt;BR /&gt;"Exit" or "Exit 0" is normally used to leave the script, and state that is ended normally.&lt;BR /&gt;Exit codes &amp;gt;= 1 are normally used to indicate some error has occured.&lt;BR /&gt;regards,&lt;BR /&gt;Thierry.</description>
      <pubDate>Fri, 27 Jul 2001 09:48:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557839#M887587</guid>
      <dc:creator>Thierry Poels_1</dc:creator>
      <dc:date>2001-07-27T09:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: exit on a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557840#M887588</link>
      <description>There's one good reason to add exit (or exit 0) at the end of every script: It documents the true end of the file.  If someone miscopies or truncates a script, there is no way to know whether all the lines are still there. By having both a comment and exit 0 such as:&lt;BR /&gt;&lt;BR /&gt;# end of script&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;then the reader will be assured that the end of the file is present.</description>
      <pubDate>Fri, 27 Jul 2001 12:28:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557840#M887588</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2001-07-27T12:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: exit on a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557841#M887589</link>
      <description>Hi Bill:&lt;BR /&gt;&lt;BR /&gt;I can't resist saying "AMEN!".  The notation of "end &lt;SOMETHING&gt;" is so desirable...on reports, in code...  At least in languages like ALGOL and PASCAL we have the enforced "END" to delineate the outer block! ;-)&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/SOMETHING&gt;</description>
      <pubDate>Fri, 27 Jul 2001 12:43:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557841#M887589</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-07-27T12:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: exit on a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557842#M887590</link>
      <description>Hi Richard,&lt;BR /&gt;&lt;BR /&gt;There is one more reason, when your script calls another scrip, there is a reliable means of checking the status.&lt;BR /&gt;e.g. &lt;BR /&gt;XXX=`somecommand.sh`&lt;BR /&gt;STAT=$?&lt;BR /&gt;&lt;BR /&gt;Now $STAT is the exit status of somecommand.sh while $XXX contains its output. &lt;BR /&gt;&lt;BR /&gt;This also should be extended to functions within your scripts.&lt;BR /&gt;&lt;BR /&gt;somefunc()&lt;BR /&gt;{&lt;BR /&gt;  FUNCSTAT=0&lt;BR /&gt;  echo "This is somefunc output \c:"&lt;BR /&gt;  while [ $# -ge 1 ]&lt;BR /&gt;    do&lt;BR /&gt;      echo "Arg ${1} \c"&lt;BR /&gt;      shift&lt;BR /&gt;    done&lt;BR /&gt;  echo&lt;BR /&gt;  return(${FUNCSTAT})&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;XXX=`somefunc 111 222`&lt;BR /&gt;STAT=$?&lt;BR /&gt;&lt;BR /&gt;Here the same rules as above apply. Typically, you test the exit(return) status before ever doing anything with the script(function) output.&lt;BR /&gt;&lt;BR /&gt;The last point is that if you do c programming the same rules apply: main() should also return a value.&lt;BR /&gt;&lt;BR /&gt;Clay</description>
      <pubDate>Fri, 27 Jul 2001 13:25:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557842#M887590</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-07-27T13:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: exit on a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557843#M887591</link>
      <description>Hi again Richard,&lt;BR /&gt;&lt;BR /&gt;Looking over the earlier replies, it appears that ravi was not quite correct. There is no default behavior associated with exit(1) or exit(0). Simply follow the standard rule:&lt;BR /&gt;0 means good; anything else not so good.&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Jul 2001 13:41:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-on-a-script/m-p/2557843#M887591</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-07-27T13:41:11Z</dc:date>
    </item>
  </channel>
</rss>

