Questions tagged [exitstatus]
78 questions
4
votes
2 answers
Bourne: if statement testing exit status
What is the difference:
if IsServerStarted ; then ...
and
if [ IsServerStarted -eq 0 ] ; then ...
Seems to me that these two statements should be equivalent? Strangely the second statement is always true.

sixtyfootersdude
- 25,859
- 43
- 145
- 213
4
votes
3 answers
How to track bash script - exit status and why it failed
Sometimes I need to run command like this:
cat file.txt | awk ' NR%4 == 2 { print $1 }' | sort | uniq -c | sort -gr >>output.txt &
over large files (2-32 GB of size). I start the command in the evening and when I come in the morning, output.txt is…

Perlnika
- 4,796
- 8
- 36
- 47
4
votes
1 answer
Perl: suppress output of backtick when file not found
In my code :
$status = `ls -l error*`;
It shows output : ls *error No such file or directory.
How can I suppress this message. I am interested in determining that the error files are generated or not. If yes, I need the list of files else ignore…

iDev
- 2,163
- 10
- 39
- 64
3
votes
3 answers
Bash $? Variable Assignement
I just started learning bash and I was reading about the $? variable. From what I understood, $? is assigned to the exit status of the last command executed.
For example
$ false; echo $?
Will yield 1, and
$ false; :; echo $?
Will yield 0
Things…

Kostas Pelelis
- 1,322
- 9
- 11
3
votes
3 answers
ld returned 1 exit status, fibonacci search
i think my "dear" code has a problem, i'm using code block and when i try to compile, the compiler show me this error: "ld returned 1 exit status"
main.c
#include
#include
#include…

alexioloruxo
- 33
- 4
3
votes
1 answer
How to catch rake task exit status in another rake task
Problem
I have something like this:
task :fail do
exit 111
end
task :run_fail_and_succeed do
begin
Rake::Task['knapsack:fail'].invoke
rescue
exit 0
end
end
I would like to run task :fail and handle it's exit status. Than exit with…

ciembor
- 7,189
- 13
- 59
- 100
3
votes
1 answer
Start server, run tests, stop server
I have a Makefile target that looks like the following
integration-test: git-hooks
java -Djava.library.path=$$(pwd)/test/integration/lib/DynamoDBLocal_lib \
-Djava.util.logging.config.file=/dev/null \
…

Alberto Zaccagni
- 30,779
- 11
- 72
- 106
2
votes
1 answer
golang cgo exit status 2 on Windows
Attempt
I want to compile the following snippet on my Windows 8.1 machine with Go 1.8.1 installed.
package main
/*
int theAnswer() {
return 42;
}
*/
import "C"
import "fmt"
func main() {
fmt.Println(C.theAnswer())
}
Here is a working…

NopMind
- 63
- 1
- 7
2
votes
2 answers
PIPESTATUS ignores negation?
I just found the following results in bash (version 4.2.25(1)-release):
$ true; echo "${PIPESTATUS[@]}"
0
$ ! true; echo "${PIPESTATUS[@]}"
0
$ false; echo "${PIPESTATUS[@]}"
1
$ ! false; echo "${PIPESTATUS[@]}"
1
$ true && false; echo…

Alfe
- 56,346
- 20
- 107
- 159
2
votes
0 answers
Gulp cryptic build error on /dist assembly
Has anyone receive this kind of error or can tell me what is going on here?
[11:11:44] Finished 'build-css-no-source' after 531 ms
[11:11:44] Starting…

Aaron Irons
- 21
- 2
2
votes
4 answers
Bourne Shell: Graceful way to get exit status
Is there a more graceful way to do this (bourne shell)?
IsThereAnyApplesLeft
applesLeft=$?
Normally in c or java I would do:
applesLeft=IsThereAnyApplesLeft

sixtyfootersdude
- 25,859
- 43
- 145
- 213
2
votes
1 answer
Exit status of tee>(...)
I am executing:
Command1 | tee >(grep sth) || Command2
I want Command2 to be executed based on the exit status of grep, while in the current configuration it is being executed based on the result of tee.
As far as I know pipefail and pipestatus…

Aman
- 1,157
- 7
- 13
2
votes
4 answers
Why does my script suddenly exit after a command?
I am trying to generate docsets for Dash following these instructions: http://kapeli.com/docsets.
The problem is, that the script doesn't continue after the wget and doesn't appear to throw any errors. Everything works fine when I copy the script…

JMH
- 1,289
- 1
- 10
- 19
2
votes
3 answers
Shell Script calls vim editor, get the exit method
I am about to write a shell script to edit some files.
I'm doing it like this:
/usr/bin/vim $file
Now i want to ask the exit status of vim.
If the user closes with saved changes do something (:wq or :x), or if closed without changes (:q, :q!) do…

Matt Backslash
- 764
- 1
- 8
- 20
2
votes
1 answer
Exit status of tar confusion
I am using ksh
dummpy_file does not exist . Finding the exit status of tar
SUSE10 / tar version GNU 1.15.1
>gunzip -d dummpy_file | tar xvf -
gunzip : dummpy_file: No such file or directory
>echo $?
>0
SUSE11 / tar version GNU 1.20
>gunzip -d…

Preetham Shenoy
- 73
- 1
- 6