<?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 commands not working in shell script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591749#M925045</link>
    <description>My apologies on the log excerpt not matching the script excerpt.  I sent only a whitewashed version of the script where the log is an actual log exerpt pretty much.  The script that generated the log is identical except that it mounts 4 instead of 3 filesystems (with different names and device files).  As you noticed, it enter the error processing portion of the code, did the echo, skipped the exit, performed the next echo and on to OmniBack, etc.  It's kind of hard to rerun it, but now is my brief window, will try with all suggestions.</description>
    <pubDate>Tue, 09 Oct 2001 15:41:42 GMT</pubDate>
    <dc:creator>Marjorie MacLean</dc:creator>
    <dc:date>2001-10-09T15:41:42Z</dc:date>
    <item>
      <title>Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591734#M925030</link>
      <description>Hi--&lt;BR /&gt;I writing a POSIX shell script on HPUX 11.0 that I intend to have exit at various points with different error codes and the exit statements are not working (they are just being ignored and the script is continuing to execute).  A smaller, simpler script containing exit codes does work when executed manually.  The script will normally be cronned, but I'm pretty sure that the problem occurs when being run manually (it is difficult to test since it contains LVM and XP commands).  Surely this can be done?</description>
      <pubDate>Tue, 09 Oct 2001 10:40:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591734#M925030</guid>
      <dc:creator>Marjorie MacLean</dc:creator>
      <dc:date>2001-10-09T10:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591735#M925031</link>
      <description>Can you post the script via an attachment? Are you using "subroutines", especially where the "exits" don't appear to work?</description>
      <pubDate>Tue, 09 Oct 2001 10:46:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591735#M925031</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2001-10-09T10:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591736#M925032</link>
      <description>if you are doing something like this:&lt;BR /&gt;&lt;BR /&gt;xpinfo | grep HP&lt;BR /&gt;&lt;BR /&gt;echo $?&lt;BR /&gt;&lt;BR /&gt;Then you'll have the exit code for the grep not the xpinfo command.&lt;BR /&gt;&lt;BR /&gt;Seperate your commands if you want to get error codes.&lt;BR /&gt;&lt;BR /&gt;Later,&lt;BR /&gt;Bill</description>
      <pubDate>Tue, 09 Oct 2001 10:54:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591736#M925032</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2001-10-09T10:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591737#M925033</link>
      <description>Thanks for your replies!  Unfortunately, I cannot post the script for confidentiality reasons.  I'm not that I'm having problems getting the right exit code, it's that the script is not exiting at all!  I'm not calling other scripts, but I am executing commands that may be forking other processes.  It's very strange that the script is continuing past the exit.  I'm wondering whether it's an issue with cron...</description>
      <pubDate>Tue, 09 Oct 2001 11:51:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591737#M925033</guid>
      <dc:creator>Marjorie MacLean</dc:creator>
      <dc:date>2001-10-09T11:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591738#M925034</link>
      <description>Can you post a whitewashed code sniplet, so that we can get a better understanding of what you mean by it ignoring "exits"?</description>
      <pubDate>Tue, 09 Oct 2001 11:58:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591738#M925034</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2001-10-09T11:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591739#M925035</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;You are probably not executing what you think you are executing.  I suggest adding 'set -x' to your script or running it with this option to print commands and their arguments as they are processed:&lt;BR /&gt;&lt;BR /&gt;# sh -x ./my.sh&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 09 Oct 2001 11:59:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591739#M925035</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-10-09T11:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591740#M925036</link>
      <description>At least in older versions, when you fall in nested loops several times, sh opens new shs to process it. &lt;BR /&gt;&lt;BR /&gt;So, and exit will not break your sh, just the new sh automaticaly generated.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Oct 2001 12:05:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591740#M925036</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2001-10-09T12:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591741#M925037</link>
      <description>Thanks again.  I'm pretty sure that I know what I'm executing... but it never hurts to double-check.  I've attached a portion of a whitewashed version.  It's pretty straight forward and does not use subroutines.</description>
      <pubDate>Tue, 09 Oct 2001 13:08:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591741#M925037</guid>
      <dc:creator>Marjorie MacLean</dc:creator>
      <dc:date>2001-10-09T13:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591742#M925038</link>
      <description>Marjorie,&lt;BR /&gt;&lt;BR /&gt;I agree with you, your script looks sound. I cut out the section that did the mount test and it worked correctly. I'm wondering if it is something in your environment, but I can't imagine what that would be.&lt;BR /&gt;&lt;BR /&gt;Do you have this posix (sh) patch installed?&lt;BR /&gt;&lt;BR /&gt;&lt;A href="ftp://ftp.itrc.hp.com/hp-ux_patches/s700_800/11.X/PHCO_23873" target="_blank"&gt;ftp://ftp.itrc.hp.com/hp-ux_patches/s700_800/11.X/PHCO_23873&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Oct 2001 14:08:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591742#M925038</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2001-10-09T14:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591743#M925039</link>
      <description>Hi Marjorie,&lt;BR /&gt;&lt;BR /&gt;That's an interesting puzzle.  There's got to be a logical explaination.  I took you attachment, commented out most things, and the exit worked fine.  I'd try some things such as:&lt;BR /&gt;&lt;BR /&gt;Try adding an exit just before: if [ "$DIRCNT" -ne 3 ]&lt;BR /&gt;&lt;BR /&gt;Try swapping the exit and echo lines (just for grins).&lt;BR /&gt;&lt;BR /&gt;Put an echo and exit just after the fi ending your DIRCNT -ne 3 logic.&lt;BR /&gt;&lt;BR /&gt;Check the log file again.  Perhaps there's a clue hidden in it.  I find it hard to believe exit is being ignored if actually seen by the shell.&lt;BR /&gt;&lt;BR /&gt;When you solve this there's a bunch of people who'd like to know the answer!  Please post it.  Thanks,&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Tue, 09 Oct 2001 14:35:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591743#M925039</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2001-10-09T14:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591744#M925040</link>
      <description>Hi Marjorie:&lt;BR /&gt;&lt;BR /&gt;There are a few POSIX sh patches that deal with exit although I didn't find any that fit yours precisely. I would install the latest cumulative patch PHCO_23873.&lt;BR /&gt;&lt;BR /&gt;The other thing I would do is put an echo after your exit in question. That way you know for sure if the problem is somehow related to loops, functions, child-processes, etc.&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Oct 2001 14:38:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591744#M925040</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-10-09T14:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591745#M925041</link>
      <description>Here's the log excerpt minus stderr (There's nothing in stderr).  As you can see, it just keeps on truckin'!</description>
      <pubDate>Tue, 09 Oct 2001 14:52:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591745#M925041</guid>
      <dc:creator>Marjorie MacLean</dc:creator>
      <dc:date>2001-10-09T14:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591746#M925042</link>
      <description>Hi Marjorie:&lt;BR /&gt;&lt;BR /&gt;I simply cannot reproduce this. I even tried some very creative uses of the trap cmd 0 statement to try to cause the exit to be ignored. I thought I saw one construct which could cause problems. Your echo "something "$XX" something else" which really outght to have the enclosed quotes escaped -&amp;gt; echo "something \"${XX}\" something else" - but that didn't do anything fix it. &lt;BR /&gt;&lt;BR /&gt;My next suggestion is twofold.&lt;BR /&gt;&lt;BR /&gt;1) Put an echo "Set: ${-}" statement in so that you can see any options set.&lt;BR /&gt;&lt;BR /&gt;2) Put some probes in very early in your code with an exit statement.</description>
      <pubDate>Tue, 09 Oct 2001 15:20:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591746#M925042</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-10-09T15:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591747#M925043</link>
      <description>Hello Marjorie,&lt;BR /&gt;&lt;BR /&gt;I do believe your problem stems from the use&lt;BR /&gt;of "ls ...|wc -l" in your script. If you do &lt;BR /&gt;this interactively, then "ls" does behave &lt;BR /&gt;differently than in scripts! Try using the&lt;BR /&gt;option "-1" (read: dash one) for the "ls",&lt;BR /&gt;then try again - and this time start your &lt;BR /&gt;script with "sh -v -x yourscript"...&lt;BR /&gt;Then you will see the command BEFORE and AFTER &lt;BR /&gt;the shell does the substitution.&lt;BR /&gt;BTW, if you insert something like&lt;BR /&gt;exec 2&amp;gt;&amp;amp;1 &amp;gt; $LOG&lt;BR /&gt;as one of the first lines in your script, then&lt;BR /&gt;you do not need all those "&amp;gt;&amp;gt; $log" in all the&lt;BR /&gt;lines :-)&lt;BR /&gt;&lt;BR /&gt;Good luck,&lt;BR /&gt;Wodisch</description>
      <pubDate>Tue, 09 Oct 2001 15:25:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591747#M925043</guid>
      <dc:creator>Wodisch</dc:creator>
      <dc:date>2001-10-09T15:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591748#M925044</link>
      <description>Marjorie,&lt;BR /&gt;&lt;BR /&gt;In looking at the logs and the script you submitted, I see that when the DIRCNT is NOT EQUAL to 3, this should exit.  But in the log I see that the DIRCNT was equal to three by the line :&lt;BR /&gt;&lt;BR /&gt;Only 3 filesystems mounted&lt;BR /&gt;&lt;BR /&gt;Not sure if this will trigger something for someone, but its looks to me as though the DIRCNT was equal to 3, but the script tried to exit anyway...&lt;BR /&gt;&lt;BR /&gt;Anyone?&lt;BR /&gt;&lt;BR /&gt;-Tim&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Oct 2001 15:28:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591748#M925044</guid>
      <dc:creator>Timothy Czarnik</dc:creator>
      <dc:date>2001-10-09T15:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Exit commands not working in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591749#M925045</link>
      <description>My apologies on the log excerpt not matching the script excerpt.  I sent only a whitewashed version of the script where the log is an actual log exerpt pretty much.  The script that generated the log is identical except that it mounts 4 instead of 3 filesystems (with different names and device files).  As you noticed, it enter the error processing portion of the code, did the echo, skipped the exit, performed the next echo and on to OmniBack, etc.  It's kind of hard to rerun it, but now is my brief window, will try with all suggestions.</description>
      <pubDate>Tue, 09 Oct 2001 15:41:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/exit-commands-not-working-in-shell-script/m-p/2591749#M925045</guid>
      <dc:creator>Marjorie MacLean</dc:creator>
      <dc:date>2001-10-09T15:41:42Z</dc:date>
    </item>
  </channel>
</rss>

