No announcement yet.

Message QSH0005 The command ended normally with the exit status 2

  • Filter
  • Time
  • Show
Clear All
new posts

  • Message QSH0005 The command ended normally with the exit status 2

    Hi all
    in a CL program i run this command :
    QSH CMD('cd /tmp/ETELENEW  ;  jar -cfM  aa.426_20220616132202.ZIP  aa.426_20220616132202.csv
    some times works and other we receive "QSH0005 The command ended normally with the exit status 2" ..
    how can understand which is the problem ?
    Thanks in advance

  • #2
    Native IBM i programs (such as OPM or ILE programs) typically work by ending with no messages when they are successful, or if they are unsuccessful they end with an *ESCAPE message (sometimes called a "halt" or "exception."). That message tells you what is wrong, and is also included in the job log.

    Unix programs are different. Unix systems don't have job logs. Operating system detected problems (such as memory violations) are sent as "signals", but any application-defined errors are handled within the application logic rather than having a mechanism like *ESCAPE messages.

    When a Unix program ends, it always sets an "exit status." This is simply an integer/number that every progam sets, and can set any way they like. The most common convention used by almost all Unix software is to set the exit status to 0 to indicate "success", or another value to indicate an error. The meanings of those numbers varies from program-to-program, each program is different. But, 0 almost always means success, and numbers higher than 0 almost always mean failure.

    Unix programs are also provided with an output stream "stderr" (standard error) that can be used to print error messages. These are usually printed to the screen to tell the user what went wrong, but can potentially be redirected to files or other programs.

    Now that you know all of that background, your message means that the "jar" program encountered an error. We know this because it is returning exit status 2, which is higher than 0. We don't know what 2 means, specifically, you'd need to find that in the documentation for the "jar" program (if it is documented at all.). Most likely, though, the number 2 isn't significant. The fact that it is not zero is all you really need to know, it means that an error occurred. To find the specific error, you'd look at the stderr data. By default, QSH will print this on the screen. You may be doing something to send it somewhere else, however (which I highly recommend if this is being run from with a program) in which case you should look wherever you are redirecting it.