<?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 command &amp;quot;not found&amp;quot; exit code different when in an interactive shell in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/command-quot-not-found-quot-exit-code-different-when-in-an/m-p/5026514#M97422</link>
    <description>I am trying to find a clean and simple way of determining if a command was "not found" (or if it was found having a non zero exit code).&lt;BR /&gt;&lt;BR /&gt;Interactively I get:&lt;BR /&gt;__________________&lt;BR /&gt;&lt;BR /&gt;&amp;gt;  CheckEnvironment.sh&lt;BR /&gt;sh: CheckEnvironment.sh:  not found&lt;BR /&gt;&amp;gt; echo $?&lt;BR /&gt;127&lt;BR /&gt;__________________&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But performing similar logic from within a script I get (with set -x on):&lt;BR /&gt;___script________&lt;BR /&gt;&lt;BR /&gt;CheckEnvironment.sh $0 $File&lt;BR /&gt;if [ $? -ne 0 ]&lt;BR /&gt;___output________&lt;BR /&gt;+ CheckEnvironment.sh ./start_RMS_services.sh.in /tmp/start_RMS_services.sh.in.1028238.errors&lt;BR /&gt;/tmp/start_RMS_services.sh.in.1028238.sh[23]: CheckEnvironment.sh:  not found&lt;BR /&gt;+ [ 0 -ne 0 ]&lt;BR /&gt;__________________&lt;BR /&gt;&lt;BR /&gt;So how can I tell if a command is "not found" within a script?&lt;BR /&gt;&lt;BR /&gt;(Note: I am hoping to whereis or which etc.)&lt;BR /&gt;</description>
    <pubDate>Sun, 04 Feb 2007 21:36:48 GMT</pubDate>
    <dc:creator>Daavid Turnbull</dc:creator>
    <dc:date>2007-02-04T21:36:48Z</dc:date>
    <item>
      <title>command "not found" exit code different when in an interactive shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-quot-not-found-quot-exit-code-different-when-in-an/m-p/5026514#M97422</link>
      <description>I am trying to find a clean and simple way of determining if a command was "not found" (or if it was found having a non zero exit code).&lt;BR /&gt;&lt;BR /&gt;Interactively I get:&lt;BR /&gt;__________________&lt;BR /&gt;&lt;BR /&gt;&amp;gt;  CheckEnvironment.sh&lt;BR /&gt;sh: CheckEnvironment.sh:  not found&lt;BR /&gt;&amp;gt; echo $?&lt;BR /&gt;127&lt;BR /&gt;__________________&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But performing similar logic from within a script I get (with set -x on):&lt;BR /&gt;___script________&lt;BR /&gt;&lt;BR /&gt;CheckEnvironment.sh $0 $File&lt;BR /&gt;if [ $? -ne 0 ]&lt;BR /&gt;___output________&lt;BR /&gt;+ CheckEnvironment.sh ./start_RMS_services.sh.in /tmp/start_RMS_services.sh.in.1028238.errors&lt;BR /&gt;/tmp/start_RMS_services.sh.in.1028238.sh[23]: CheckEnvironment.sh:  not found&lt;BR /&gt;+ [ 0 -ne 0 ]&lt;BR /&gt;__________________&lt;BR /&gt;&lt;BR /&gt;So how can I tell if a command is "not found" within a script?&lt;BR /&gt;&lt;BR /&gt;(Note: I am hoping to whereis or which etc.)&lt;BR /&gt;</description>
      <pubDate>Sun, 04 Feb 2007 21:36:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-quot-not-found-quot-exit-code-different-when-in-an/m-p/5026514#M97422</guid>
      <dc:creator>Daavid Turnbull</dc:creator>
      <dc:date>2007-02-04T21:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: command "not found" exit code different when in an interactive shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-quot-not-found-quot-exit-code-different-when-in-an/m-p/5026515#M97423</link>
      <description>Note should read:&lt;BR /&gt;(Note: I am hoping to avoid using whereis or which etc.)</description>
      <pubDate>Sun, 04 Feb 2007 21:43:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-quot-not-found-quot-exit-code-different-when-in-an/m-p/5026515#M97423</guid>
      <dc:creator>Daavid Turnbull</dc:creator>
      <dc:date>2007-02-04T21:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: command "not found" exit code different when in an interactive shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-quot-not-found-quot-exit-code-different-when-in-an/m-p/5026516#M97424</link>
      <description>Which interactive shell?&lt;BR /&gt;Which shell for the script?</description>
      <pubDate>Sun, 04 Feb 2007 21:52:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-quot-not-found-quot-exit-code-different-when-in-an/m-p/5026516#M97424</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2007-02-04T21:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: command "not found" exit code different when in an interactive shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-quot-not-found-quot-exit-code-different-when-in-an/m-p/5026517#M97425</link>
      <description>Doh!!&lt;BR /&gt;&lt;BR /&gt;I worked it out.&lt;BR /&gt;&lt;BR /&gt;My issue was that I was creating the script as an inline file and had neglected to escape the $0... which was of course 0 at the point when the script was being produced... so this code always passed the test:&lt;BR /&gt;________&lt;BR /&gt;CheckEnvironment.sh ./start_RMS_services.sh.in /tmp/start_RMS_services.sh.in.938148.errors&lt;BR /&gt;if [ 0 -ne 0 ]&lt;BR /&gt;then&lt;BR /&gt;________&lt;BR /&gt;&lt;BR /&gt;I shall close this thread now to avoid embarrassing replies ;-)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 04 Feb 2007 23:05:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-quot-not-found-quot-exit-code-different-when-in-an/m-p/5026517#M97425</guid>
      <dc:creator>Daavid Turnbull</dc:creator>
      <dc:date>2007-02-04T23:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: command "not found" exit code different when in an interactive shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-quot-not-found-quot-exit-code-different-when-in-an/m-p/5026518#M97426</link>
      <description>See comments above</description>
      <pubDate>Sun, 04 Feb 2007 23:07:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-quot-not-found-quot-exit-code-different-when-in-an/m-p/5026518#M97426</guid>
      <dc:creator>Daavid Turnbull</dc:creator>
      <dc:date>2007-02-04T23:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: command "not found" exit code different when in an interactive shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-quot-not-found-quot-exit-code-different-when-in-an/m-p/5026519#M97427</link>
      <description>For a real shell, there is a whence builtin.  It returns no output but exit status of 1.&lt;BR /&gt;&lt;BR /&gt;You may have to use "set +e" to turn off errexit when you do the whence in non-iteractive shells.</description>
      <pubDate>Mon, 05 Feb 2007 22:40:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-quot-not-found-quot-exit-code-different-when-in-an/m-p/5026519#M97427</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-02-05T22:40:12Z</dc:date>
    </item>
  </channel>
</rss>

