Questions tagged [exitstatus]

78 questions
299
votes
9 answers

How to exit if a command failed?

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.…
user459246
  • 3,139
  • 2
  • 15
  • 7
102
votes
5 answers

How can I check the first character in a string in Bash or Unix shell?

I'm writing a script in Unix where I have to check whether the first character in a string is "/" and if it is, branch. For example, I have a string: /some/directory/file I want this to return 1, and: server@10.200.200.20:/some/directory/file to…
canecse
  • 1,772
  • 3
  • 16
  • 20
87
votes
2 answers

What is the authoritative list of Docker Run exit codes?

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…
jeesty
  • 1,124
  • 1
  • 10
  • 13
40
votes
3 answers

Meaning of exit status 1 returned by linux command

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?
user2664054
  • 541
  • 1
  • 5
  • 9
16
votes
7 answers

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

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…
Rob Bednark
  • 25,981
  • 23
  • 80
  • 125
16
votes
4 answers

How to make Fabric continue running the next command after getting the exit status: 1?

I'm going to install check_mk plugin by writing a simple fabfile like this: from fabric.api import env, run, roles, execute, parallel env.roledefs = { 'monitoring': ['192.168.3.118'], 'mk-agent': ['192.168.3.230', '192.168.3.231',…
quanta
  • 3,960
  • 4
  • 40
  • 75
15
votes
2 answers

Bash exit status of shorthand increment notation

I noticed an apparent inconsistency in the return status of bash's (( )) notation. Consider the following $> A=0 $> ((A=A+1)) $> echo $? $A 0 1 However using the other well known shorthand increment notation yields: $> A=0 $> ((A++)) $> echo $?…
Pankrates
  • 3,074
  • 1
  • 22
  • 28
10
votes
4 answers

angular2 quickstart npm install fails

I get the following error when I try to run- npm install. error as below: npm ERR! node v0.12.12 npm ERR! npm v3.3.6 npm ERR! code ELIFECYCLE npm ERR! angular2-quickstart@1.0.0 postinstall: `typings install` npm ERR! Exit status 1 npm…
Smitha
  • 6,110
  • 24
  • 90
  • 161
10
votes
1 answer

ffmpeg exit status -1094995529

I'm developing an application that makes calls to ffprobe that return the unorthodox exit status of -1094995529 for certain files when on Windows. This exit status is given consistently, and there is some minor discussion of this. Why is this value…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
8
votes
4 answers

In Python: how can I get the exit status of the previous process run from Bash (i.e. "$?")?

I have a Python script that should report success or failure of the previous command. Currently, I'm doing command && myscript "Success" || myscript "Failed" What I would like to do is instead to be able to run the commands unlinked as in: command;…
Miquel
  • 15,405
  • 8
  • 54
  • 87
7
votes
0 answers

Maven returns an exit status of 0 even for failed builds?

I am using Maven v2.2.1 on my linux box. I have a build script that invokes mvn and does something based on the build status. I noticed that the exit status code is set to 0 irrespective of whether the mvn build fails or succeeds. I also came…
Tushar
  • 81
  • 5
7
votes
5 answers

unix shell, getting exit code with piped child

Let's say I do this in a unix shell $ some-script.sh | grep mytext $ echo $? this will give me the exit code of grep but how can I get the exit code of some-script.sh EDIT Assume that the pipe operation is immutable. ie, I can not break it apart…
Mike
  • 58,961
  • 76
  • 175
  • 221
5
votes
2 answers

Does exit code status with zero value always mean successfully run in Perl?

I have a Perl script that will execute three applications. All of it have different exit code status. First application exit code status is 1. The application exited normally without any problem. (Successful) Second application exit code status is…
quinekxi
  • 879
  • 5
  • 14
  • 27
4
votes
1 answer

Return data type of the function in c programming

i have to use exit(1) command in a function. Does it have anything to do with the return data type of the function in which it is being used?
user1005284
4
votes
2 answers

Exit with non-zero if input is empty

I am trying to parse my curl output with JQ and check the exit code, so when my curl output is empty, JQ return 0 exit code. For example: $ echo "" | jq '.key' $ echo $? 0 How to make this return 1 or some non-zero value?
James Sapam
  • 16,036
  • 12
  • 50
  • 73
1
2 3 4 5 6