gautam vegeta
gautam vegeta

Reputation: 653

Capturing the return code from java in a shell script

I am invoking a java program from a shell script "TC Shell Script" and the java program returns status codes which represent certain conditions.

The return code of the java prgram is captured in the pre-defined status variable of the TC Shell.

The return codes are captured fine.

The problem I'm facing is when the java program returns or terminates with -1 with System.exit(-1) the shell script is getting 255 as the return code.

All positive numbers are captured fine in the shell script only -1 is being read as 255.

How can i solve this.

Upvotes: 2

Views: 1436

Answers (1)

tripleee
tripleee

Reputation: 189387

Return codes from executables are a small positive number. Negative numbers get converted to unsigned. There is no way to get a negative number into the exit code.

Upvotes: 3

Related Questions