FAQ Database Discussion Community


How exactly works the Java application exit code of the main() method?

java,java-ee,main,exit-code
I have the following doubts related a simple command line Java application. So I have this command line application that is startd by a main() method definied inside a Main class. As usual this main() method is definied with this signature: public static void main(String[] args) { So it return...

How to get the an exit status while using declare to “declare” a variable bash

bash,variables,exit-code,declare,whiptail
I'm using declare along with whiptail to create a variable. The user input from whiptail is defined as the variable with declare. I want to use the exit status from whiptail (i.e cancel or esc) but I just get the exit code from the declare statement? Here is piece of...

Hello world exit code

exit-code
I just compiled my hello world c program with gcc and ran it in ubuntu. Since I ran it through emacs, I got the exit code of the program: 13. Why 13? I didn't specify anything, so why didn't it default to 0? When I put an exit function at...

Getting the exit code of an application started with the “cmd” and “start” commands

windows,batch-file,console-application,command-prompt,exit-code
I have a console application. Interaction with this application is done via TCP/IP. I also have a test framework for it, which is basically a collection of BATCH scripts (...not my fault). What this test framework does for each test is basically this: start /min "myapplication.exe" and wait until verification...

Why does ln from Python subprocess fail while it succeeds from normal command line?

python,bash,subprocess,exit-code,ln
As the title says: >>> from subprocess import check_output >>> check_output(['ln', '~/other_folder/src/models/sc_models.py', './src/models/sc_models.py']) Traceback (most recent call last): File "<input>", line 1, in <module> File "/usr/lib/python2.7/subprocess.py", line 573, in check_output raise CalledProcessError(retcode, cmd, output=output) CalledProcessError: Command '['ln', '~/other_folder/src/models/sc_models.py', './src/models/sc_models.py']' returned non-zero exit status 1 >>> exit() $ ln...

Passing shell command to a terminal application from an App in Mac

python,osx,argument-passing,exit-code,py2app
I have frozen a python based GUI script using Py2app successfully but I run into trouble using this app on Mac. This app is supposed to send arguments/parameters to Clustal, a terminal-based application, but it instead returns an error non-zero exit status 127, '/bin/sh: clustal: command not found'. I found...

Best practices on setting exit status codes

bash,shell,exit-code
When implementing my own scripts, is it the best practice to exit with different exit codes for different failure scenarios? Or should I just return exit code 1 for failure and 0 for success providing the reason on stderr?

Press Enter to exit While Loop in Python 3.4

python,python-3.x,while-loop,exit-code
I am new to Python and have been teaching myself over the past few months. The book I am using teaches Python 2.7, while I am trying to learn Python in 3.4. I've become accustomed to using both now, but for the life of me I can't figure out how...

Predictable exit code of crashed process in Windows

c++,windows,crash,exit-code
For a process exiting normally in Windows, the exit code of the process is generally either the return value from main, or the exit code passed to std::exit. %ERRORLEVEL% can then be used to query the exit code, and that can be used to determine whether the program executed either...

Eclipse Java application: Returning exit code \= 0 opens unwanted window

java,eclipse,exit-code
We're building an application in Java based on Eclipse. Its entry point implements IApplication. The exit code is set by method start(). The problem is that if the exit code is not 0, Eclipse presents a dialog box saying "Java was started but returned exit code=...". After the user closes...

Docker Compose with one Terminating Container

docker,exit,exit-code,docker-compose,fig
I'm having a docker compose setup of a database container, an application container and one container which pre-loads the database with necessary data. I want to start all of the containers together with docker-compose up while the pre-loading container terminates after it is one with exit 0. But terminating this...

exit fails to set error code

c++,windows,windows-server-2008,exit-code
I have a C++ Windows program that fails to set the exit code. The program is very complex and I'm currently unable to reproduce this with a simple test case. I do know that the program calls exit(1) because I have a breakpoint on that line. Immediately after I step...

How to use process to run several commands

c#,process,exit-code
I have a process , use it to run several commands. Process mycmd = new Process(); mycmd.StartInfo = startInfo1; mycmd.Start(); if (mycmd.ExitCode > 0) { // do something } mycmd.StartInfo = startInfo2; mycmd.Start(); if (mycmd.ExitCode > 0) { // do something else } First time the command is executed the...

How to properly report an exit status in batch?

python,windows,batch-file,exit-code
I'm facing a weird situation where a batch file I wrote reports an incorrect exit status. Here is a minimal sample that reproduces the problem: bug.cmd echo before if "" == "" ( echo first if exit /b 1 if "" == "" ( echo second if ) ) echo...