exitstatus

How to tell if any command in bash script failed (non-zero exit status)

跟風遠走 提交于 2019-11-30 12:24:08
I want to know whether any commands in a bash script exited with a non-zero status. I want something similar to set -e functionality, except that I don't want it to exit when a command exits with a non-zero status. I want it to run the whole script, and then I want to know that either: a) all commands exited with exit status 0 -or- b) one or more commands exited with a non-zero status e.g., given the following: #!/bin/bash command1 # exits with status 1 command2 # exits with status 0 command3 # exits with status 0 I want all three commands to run. After running the script, I want an indication

What is the authoritative list of Docker Run exit codes?

一曲冷凌霜 提交于 2019-11-28 18:11:33
Apologies if this has been asked, but nowhere in the Docker documentation can I find an authoritative list of exit codes (also called exit status). Surprising! I see suggestions about making it consistent, but no docs on docker.com. Does anyone know where the exit codes can be found? Tombart For Docker >= 1.10 see this PR , which follows standard chroot exit codes : 125 : docker run itself fails 126 : contained command cannot be invoked 127 : if contained command cannot be found 128 + n Fatal error signal n : 130 = (128+2) Container terminated by Control-C 137 = (128+9) Container received a

What is the authoritative list of Docker Run exit codes?

心已入冬 提交于 2019-11-27 10:59:30
问题 Apologies if this has been asked, but nowhere in the Docker documentation can I find an authoritative list of exit codes (also called exit status). Surprising! I see suggestions about making it consistent, but no docs on docker.com. Does anyone know where the exit codes can be found? 回答1: For Docker >= 1.10 see this PR, which follows standard chroot exit codes: 125 : docker run itself fails 126 : contained command cannot be invoked 127 : if contained command cannot be found 128 + n Fatal

How to exit if a command failed?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 05:54:58
I am a noob in shell-scripting. I want to print a message and exit my script if a command fails. I've tried: my_command && (echo 'my_command failed; exit) but it does not work. It keeps executing the instructions following this line in the script. I'm using Ubuntu and bash. Try: my_command || { echo 'my_command failed' ; exit 1; } Four changes: Change && to || Use { } in place of ( ) Introduce ; after exit and spaces after { and before } Since you want to print the message and exit only when the command fails ( exits with non-zero value) you need a || not an && . cmd1 && cmd2 will run cmd2

Meaning of exit status 1 returned by linux command

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 02:42:28
问题 What is meaning of exit status 1 returned by linux command? Like 127 exit status indicates "command not found". I have visited http://linux.die.net/abs-guide/exitcodes.html page, does it mean exit status 1 does not have particular special meaning? 回答1: The only general convention is that a zero exit status signifies success, whereas any non-zero exit status is a failure. Many -- but certainly not all -- command-line tools return exit code 1 for syntax error, i.e. you had too few arguments or

How to exit if a command failed?

随声附和 提交于 2019-11-26 11:47:19
问题 I am a noob in shell-scripting. I want to print a message and exit my script if a command fails. I\'ve tried: my_command && (echo \'my_command failed; exit) but it does not work. It keeps executing the instructions following this line in the script. I\'m using Ubuntu and bash. 回答1: Try: my_command || { echo 'my_command failed' ; exit 1; } Four changes: Change && to || Use { } in place of ( ) Introduce ; after exit and spaces after { and before } Since you want to print the message and exit