<?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: Error Codes in shell script. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314119#M186151</link>
    <description>Hi Sunil,&lt;BR /&gt;&lt;BR /&gt;You can try to capture the standard o/p and err to a file .&lt;BR /&gt;&lt;BR /&gt;mv file1 file2 &amp;gt;mv.log 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;The log file should contain the errors message .&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;BL.</description>
    <pubDate>Thu, 24 Jun 2004 05:34:40 GMT</pubDate>
    <dc:creator>blal</dc:creator>
    <dc:date>2004-06-24T05:34:40Z</dc:date>
    <item>
      <title>Error Codes in shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314116#M186148</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt; I wanted to know how can i trap the exact &lt;BR /&gt;error code and error message within the shell script for "mv " command to know what caused the actual problem ..ie was it file permission erro or no space on target or something else.&lt;BR /&gt;&lt;BR /&gt;Are there any specific codes reflected and how can i trap them.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;&lt;BR /&gt;Sunil</description>
      <pubDate>Thu, 24 Jun 2004 05:22:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314116#M186148</guid>
      <dc:creator>sunil_34</dc:creator>
      <dc:date>2004-06-24T05:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Error Codes in shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314117#M186149</link>
      <description>Each command returns a status when it terminates. If it is unsuccessful, it&lt;BR /&gt;returns a code which tells the shell to print an error message. &lt;BR /&gt;&lt;BR /&gt;The default exit (no arguments) will exit the shell program with the status of&lt;BR /&gt;the last command executed. You can exit with a diferent exit status; see the&lt;BR /&gt;man pages for the exit statuses of each command. The usual exit&lt;BR /&gt;statuses are:&lt;BR /&gt;&lt;BR /&gt;0 Success.&lt;BR /&gt;1 A built-in command failure.&lt;BR /&gt;2 A syntax error has occurred.&lt;BR /&gt;3 Signal received that is not trapped&lt;BR /&gt;&lt;BR /&gt;sks</description>
      <pubDate>Thu, 24 Jun 2004 05:32:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314117#M186149</guid>
      <dc:creator>Sanjay Kumar Suri</dc:creator>
      <dc:date>2004-06-24T05:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Error Codes in shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314118#M186150</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can do a set +x in the beginning of the script to see the script execution.&lt;BR /&gt;The error message coming out of mv will be sent to stderr so you can redirect the output to a file 2&amp;gt;file and see the error message.&lt;BR /&gt;&lt;BR /&gt;apart from that I cannot think of anything now.&lt;BR /&gt;&lt;BR /&gt;manish</description>
      <pubDate>Thu, 24 Jun 2004 05:33:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314118#M186150</guid>
      <dc:creator>Manish Srivastava</dc:creator>
      <dc:date>2004-06-24T05:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Error Codes in shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314119#M186151</link>
      <description>Hi Sunil,&lt;BR /&gt;&lt;BR /&gt;You can try to capture the standard o/p and err to a file .&lt;BR /&gt;&lt;BR /&gt;mv file1 file2 &amp;gt;mv.log 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;The log file should contain the errors message .&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;BL.</description>
      <pubDate>Thu, 24 Jun 2004 05:34:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314119#M186151</guid>
      <dc:creator>blal</dc:creator>
      <dc:date>2004-06-24T05:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Error Codes in shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314120#M186152</link>
      <description>Yeah Sanjay i know about the error codes&lt;BR /&gt;like 0,1,2  but i believe their are some specifice error codes addressing some specific error messages viz. permission error&lt;BR /&gt;,space error etc. &lt;BR /&gt;&lt;BR /&gt;How can i trap this erros in my shell scripts&lt;BR /&gt;to reflect the actual error.&lt;BR /&gt;&lt;BR /&gt;regrds,&lt;BR /&gt;Sunil.&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Jun 2004 05:36:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314120#M186152</guid>
      <dc:creator>sunil_34</dc:creator>
      <dc:date>2004-06-24T05:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Error Codes in shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314121#M186153</link>
      <description>Hi,&lt;BR /&gt;Don't know your script but,&lt;BR /&gt;echo $?&lt;BR /&gt;This will display the error code generated by the earlier command.&lt;BR /&gt;Maybe this will help you.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Jun 2004 05:44:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314121#M186153</guid>
      <dc:creator>Shaikh Imran</dc:creator>
      <dc:date>2004-06-24T05:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: Error Codes in shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314122#M186154</link>
      <description>Hi Sunil,&lt;BR /&gt;&lt;BR /&gt;The specific error which you can generate in a C program (syscall failure) like permission denied cannot be trapped in a shell script if the application (mv) is not givint it to the script.&lt;BR /&gt;&lt;BR /&gt;manish</description>
      <pubDate>Thu, 24 Jun 2004 05:46:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314122#M186154</guid>
      <dc:creator>Manish Srivastava</dc:creator>
      <dc:date>2004-06-24T05:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Error Codes in shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314123#M186155</link>
      <description>Sunil,&lt;BR /&gt;&lt;BR /&gt;The only way this can be done is to trap the actual numeric value (0, 1, 2, etc) via the $? variable.  I do this as follows:&lt;BR /&gt;&lt;BR /&gt;mv &lt;FILE&gt; &lt;NEWFILE&gt; &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;rval=$?&lt;BR /&gt;&lt;BR /&gt;Then I can test the value of rval (because $? is constantly changing).&lt;BR /&gt;&lt;BR /&gt;Now, as to getting the actual error, you need to learn what the various return codes are (either via man pages or experimentation).  To display a meaningful text message, you can do something like this:&lt;BR /&gt;&lt;BR /&gt;case ${rval} &lt;BR /&gt;in&lt;BR /&gt;   0) MESSAGE="Move successful";;&lt;BR /&gt;   1) MESSAGE="Out of disk space";;&lt;BR /&gt;   2) MESSAGE="File not found";;&lt;BR /&gt;   *) MESSAGE="Unknown error - return code is ${rval}";;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;I've made up the messages for 1 and 2 (just to provide an example).  &lt;BR /&gt;&lt;BR /&gt;Over time, as you get "Unknown error - return code is ___" you just add on to the script and build up the case statement.&lt;/NEWFILE&gt;&lt;/FILE&gt;</description>
      <pubDate>Thu, 24 Jun 2004 08:09:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-codes-in-shell-script/m-p/3314123#M186155</guid>
      <dc:creator>Gary L. Paveza, Jr.</dc:creator>
      <dc:date>2004-06-24T08:09:32Z</dc:date>
    </item>
  </channel>
</rss>

