Questions tagged [exit-status]

Use this tag If your question revolves around determining or utilizing the exit status (return code) of a command. Common syntax involves the $? variable and the && and || symbols.

0
votes
1answer
843 views

exit status and no output

I have a command such that bar > /dev/null and I want to know the exit status of bar. I read some posts su about ${PIPESTATUS[0]} but this works when one pipes the output via | and I can't make ...
0
votes
2answers
228 views

What is Linux exit status and list of all status

I'm trying to learn Linux bash scripting and I'm read through the articles in the http://tldp.org sites I saw some kind log clearing scripting I notice that something is used for as an exit status. I ...
0
votes
1answer
44 views

Allow automated script to incorporate git rebase

I have this in a script: set -e; base="remotes/origin/dev"; git checkout --no-track -b "$new_branch"; git rebase "$base"; on occasion, there are conflicts of course, and what happens is that git ...
0
votes
2answers
66 views

How do I make this script output: “Error connecting to Mom via SSH” when connection is down?

Intention I am in the middle of writing a little shell script (POSIX, except for the system_beep()). The script, which runs in Cygwin, should find out, if my mother's laptop is closed or not and ...
0
votes
1answer
627 views

How can I run the same command multiple times in series and capture all exit codes?

I am running an end-to-end test suite that's quite flakey, and I'd like a way to determine which tests are the flakiest. The easiest approach it seems would be to run tests 100s of times and return a ...
0
votes
1answer
33 views

Checking if a command fails - After redirects or before?

We have an SQL script that we execute while redirecting STDOUT and STDERR to two separate files. Due to recent problems with the SQL script, we want to exit the script with an error in the event the ...
0
votes
2answers
87 views

Shell script for executing programs within a loop and checking their exit values

How do I do this in a shell script: for (int i=0;i<1000;i++) { run applicationA run applicationB if (retvalFromApplicationB!=0) {continue;} else {pipe ouptut (stdout) from ...
0
votes
2answers
2k views

breaking out of command loop but exit code not the reason?

I run the following: echo "while emacs;do echo $?;done;echo Exit code: $?;" | bash If I exit emacs through the menu or the close button, it prints exit code 0 and restarts. If I exit emacs through ...
0
votes
1answer
40 views

Why testing return value from fgrep always false in below code?

I have the below script to find missing items from fileA compared to fileB and write to fileC script.sh fileA fileB fileC script.sh: rm $3 while IFS="" read -r inputline; do fgrep -q \""$inputline"...
0
votes
1answer
32 views

What happens when we run var=3 command [duplicate]

Below I run what I expected to be an invalid command: var=3 date, which in fact isn't. $ var=3 date Sun May 26 17:10:22 UTC 2019 $ echo $? 0 But the variable wasn't assigned the value 3: $ echo $...
0
votes
0answers
63 views

How to enter and leave a man page in a script

I want to run a script that enters a man page and leaves it. Something like (in pseudo-code) $ man man q How can I do such a thing? Preferably the exit code will be 0. More generally how do I do ...
0
votes
0answers
61 views

C++ script on Spark Cluster throws exit status 132

I'm trying to run a c++ program on spark cluster by using the rdd.pipe() operation but the executors throw: java.lang.IllegalStateException: Subprocess exited with status 132. The spark jar runs ...
0
votes
0answers
52 views

Is it possible to “coax” arbitrary core *nix utilities into returning a non-zero exit status even when successful?

I am running bash scripts and executing bash commands on remote systems using Connectwise Automate (formerly LabTech). These systems are both Linux and MacOS. Connectwise Automate (CWA) has some ...
0
votes
0answers
947 views

Getting message “No Such File Or Directory” message with SFTP connection but file is on the server

I'm trying to figure out and I would like to know if some of you experienced this before. I have my SFTP script (before it was FTP, and was migrated to SFTP), when I'm sending a file to the client ...
-1
votes
2answers
34 views

Why doesn't back-slash yield non-zero exit code

If run: true \ false; echo $? I get an exit code of 0. Does anyone know why that is?
-1
votes
4answers
45 views

Is there a ping-like program that will return false when a packet is lost?

I'm trying to diagnose network instability on my home LAN -- I'm losing connectivity between my router and my cable modem. In my shell script, I'd like to ping the first ip address past the modem, and ...