Questions tagged [exit-code]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
0 answers
268 views

MySQL refuses to start on my Debian 10 server after a botched control panel installation attempt

Context After two failed control panel installation (tinycp and cloudpanel) attempts and a restart the MySQL service (Community version 8.0.27) is not starting. When trying to restart the service, it ...
Adrian's user avatar
  • 11
0 votes
0 answers
149 views

Debian: xinit with startx always returns exit code 0

I am starting kiosk mode application (Electron based) with startx in systemd service. I need to stop service when application is exited with specified exit code. The user running service is not in ...
Marko's user avatar
  • 1
-1 votes
1 answer
707 views

How do I set the exit code of a one line command to 1 if the result if blank?

If have a command, say echo "", and I want the exit code of that to be 1, however if I were to run the command echo "foo" I would want the status code to be 0.
Tyler Clendenin's user avatar
0 votes
1 answer
2k views

Cmd crashes with exit code 1 after uninstalling anaconda

On Win10 Pro, Cmd crashes with exit code 1 after uninstalling and reinstalling anaconda; since then, I've been unable to access Command Prompt. As soon as I open cmd, it closes, and opening within ...
Filippo Vicari's user avatar
2 votes
1 answer
520 views

CMD prompt: %ERRORLEVEL% gets the correct output value from the second run

I have wolframscript installed on my Windows 10 PC. Running the following commands on the command prompt get me > where /q wolframscript & echo %ERRORLEVEL% 9009 <<< why didn't I ...
Diaa's user avatar
  • 177
6 votes
2 answers
1k views

In a bash script, how do I check if "-e" is set? [duplicate]

I use set -e in scripts quite often, but sometimes, it's ok for a script to fail in some of it's commands. I tried checking if set -e was ON, but couldn't find a way to do it - there's no option (that ...
Moshe Gottlieb's user avatar
2 votes
2 answers
817 views

Why does `%errorlevel%` expand to empty string in DOSBox?

Trying to automate some DOSBox scripting for an old program, I wanted to use the exit code usually in errorlevel to control the program flow. The input is given in a hello_db.bat file: @echo off set ...
Morten Zilmer's user avatar
1 vote
1 answer
452 views

Why do I get this code 139 error (signal 11: SIGSEGV), and what can I do about it?

I've recently upgraded to Mac OS Catalina and my project that I have been working on keeps getting interrupted by this new error before any of the main code runs: Process finished with exit code ...
TJR's user avatar
  • 11
1 vote
2 answers
596 views

Exit Code history and best practice

I am finding a bunch of duplicate error codes when dealing with Autodesk installs and uninstalls. For example 3010 ERROR_SUCCESS_REBOOT_REQUIRED -2147021886 ERROR_SUCCESS_REBOOT_REQUIRED and 1618 ...
Gordon's user avatar
  • 211
13 votes
2 answers
2k views

How to exit with an error code from nano?

When using vim for “replying” to some program – typically git – it can be useful to deliberate exit with error, to abort the entire action that opened the window. Like $ git commit -a # vim opens, ...
leftaroundabout's user avatar
6 votes
1 answer
619 views

Use output of command as exit code

For my Continuous Integration scripts I want to check if the git branch is not in sync with the master branch. Therefore I use git rev-list --left-right --count master...my-branch-name It will ...
Sven R.'s user avatar
  • 165
1 vote
0 answers
199 views

How to get exit code of a subprocess?

So, I have process B. Typically, process B is called and ran entirely with the context of process A. Unfortunately, for some reason, process B has stopped running properly when called by A, but it ...
Sidney's user avatar
  • 1,267
1 vote
2 answers
6k views

BASH pipe exit code

I was writing a simple script that checks for a certain keyword in the output of a command. To see if it works, I was checking the command from the bash command line. $ ls | grep -q foo $ echo $? It ...
Chihaya's user avatar
  • 81
1 vote
1 answer
8k views

What does exit status 1 (0x1) mean for a Windows GUI program?

I have recurring occurrences of Internet Explorer (C:\Program Files\Internet Explorer\iexplore.exe) exiting with exit status 1 (0x1) in my Windows Eventlogs (event id 4689). Whenever I google for the ...
QuestionOverflow's user avatar
2 votes
1 answer
999 views

why doesn't "echo $?" print the exit code of the command right before it while used in "&&"?

Suppose I have this simple C program that returns 4 to the shell. int main() { return 4; } When I run it, then do echo $?, I would get 4, which is expected $ gcc foo.c && ./a.out $ echo $?...
One Two Three's user avatar
-1 votes
2 answers
2k views

Echo for status codes?

I'm looking for a tool like echo, but for status codes $ sts 120 $ echo $? 120 I know you can use a sub-shell in a bash-like environment: $ (exit 120) $ echo $? 120 but is there a way to do such ...
David Cowden's user avatar
2 votes
3 answers
7k views

Exit code 127 in cygwin64

After years without problems, suddenly several programs in my installation of cygwin64 on 64-bit Windows 7 Professional are failing to run, and instead appear to exit immediately with code 127, which ...
Tim Parenti's user avatar
3 votes
2 answers
13k views

What's the exit code for "curl -I" when not HTTP 200?

I want to check what HTTP status code is returned for an HTTP(S) URL. I don't care about content, so I just request head with curl -I $url or curl --head $url But what's the exit code I should ...
Nemo's user avatar
  • 1,134
3 votes
1 answer
3k views

Exit status of commands before last command

On OS X, Linux, and other systems, you can use $? to get the exit code of the last command. Is there any way to exit codes of older commands? Either by saying "give me the exit code of the nth ...
Amit Kumar Gupta's user avatar
1 vote
0 answers
61 views

Simulating errorlevel

My command takes long to run but I expect that it can finish with error and I want fail fast in the batch loop in this case. How do I produce the error level? I tried a batch file with exit 1. But, ...
Val's user avatar
  • 1
0 votes
1 answer
369 views

Check shell Script copy Status

I have a cron script and i need to adjust it; Actually some clients are generating in a directory some files, my task is to backup that files to a tape, and i need to make a if then else cp $files $...
user324868's user avatar
1 vote
3 answers
117 views

How to find files which do not contain their own filename

When using templates to generate files, it's important to include the template's name inside the template. When reading a generated file, it helps you find the template used to generate it. I want to ...
Craig's user avatar
  • 121
2 votes
1 answer
4k views

How do I run multiple scripts within a script, even if one script fails

I have a simple bash script that executes a number of other scripts … #/bin/bash … ./update_artifact1.sh $ARTIFACT_VERSION ./update_artifact2.sh $ARTIFACT_VERSION ./update_artifact3.sh $...
Dave's user avatar
  • 73
10 votes
3 answers
8k views

How do you use PIPESTATUS, tee and /bin/sh together?

When I run curl | tee test.txt; echo ${PIPESTATUS[0]} I correctly see curl: try 'curl --help' or 'curl --manual' for more information 2 But when I try to run exactly same command using '/bin/sh': ...
Yasser Zamani's user avatar
1 vote
1 answer
1k views

trying to install windows hotfix, but getting a negative exit code

I am trying to install windows-8-RT kb2771744 hotfix. I am getting a negative exit code: -2125124329 I converted that into hex: 7FDBFFE9 I looked around, I am not sure what to make of it.
Naz's user avatar
  • 11
530 votes
11 answers
293k views

Can I make cURL fail with an exitCode different than 0 if the HTTP status code is not 200?

I was always assuming that when curl got an HTTP 500 response it was returning an exit code that meant failure (!= 0), but that seems to be not the case. Is there a way I can I make cURL fail with an ...
knocte's user avatar
  • 5,571
1 vote
1 answer
2k views

Get errorlevel in cmd script calling ssh

ssh -i private_linux_key user@machine "exit 1" || echo %errorlevel% This always prints 0. How can I get actual error code returned by ssh? || somehow detects that there was an error.
Roman's user avatar
  • 161
9 votes
4 answers
8k views

Accessing an exit code outside of a su -m $USER -c "<cmd>"

The below command prints "0" or "1" correctly depending on failure or not because i put $? inside the "su" command. sudo su -m $USER -c "./shutdown.sh &> /dev/null; echo \$?" However, if i do ...
Nick's user avatar
  • 505
4 votes
1 answer
4k views

How do I invert the exit code of a program or pipe within ZSH?

I want to invert the exit code of a piped command sequence: foo | bar within the ZSH. So 0 maps to 1 and 1-128 maps to 0.
math's user avatar
  • 2,633
4 votes
2 answers
36k views

exit code 128, what's the reason?

As per definition exit code 128 means 'invalid exit argument'. But i always get 255 (Exit status out of range) in case argument is invalid like float number. Is this the proprietary implementation ...
P K's user avatar
  • 2,183
55 votes
2 answers
21k views

Can I make SSH fail when a port forwarding fails?

If I do a remote port forward, a la -R 3690:localhost:3690 when a binding already exists on the port on the remote host, I get this warning: Warning: remote port forwarding failed for listen port ...
Matt Joiner's user avatar
  • 1,064
19 votes
2 answers
15k views

How to make TaskScheduler fail when the task returns result different from 0

I have a backup task that fails with a non zero result, yet Task Scheduler says that it executed the task correctly. Is there any way to tell Task Scheduler that the task failed?
Pablo Montilla's user avatar
150 votes
12 answers
127k views

Getting ROBOCOPY to return a "proper" exit code?

Is it possible to ask ROBOCOPY to exit with an exit code that indicates success or failure? I am using ROBOCOPY as part of my TeamCity build configurations, and having to add a step to just silence ...
Lasse V. Karlsen's user avatar
2 votes
1 answer
4k views

How to check return status of command invoked from command line in windows?

reg import RegFile.reg How to check return code of this command ?
Ashish's user avatar
  • 187