Sql*plus always returns exit code 0?

You have to explicitly tell sqlplus to do that, in your script. Basically, there are two statements that you can use: WHENEVER SQLERROR EXIT SQL.SQLCODE WHENEVER OSERROR EXIT For example: WHENEVER SQLERROR EXIT SQL.SQLCODE begin SELECT COLUMN_DOES_NOT_EXIST FROM DUAL; END; / And for OS errors: WHENEVER OSERROR EXIT FAILURE START no_such_file For more information, see … Read more

PowerShell and process exit codes

Current as of PowerShell (Core) 7.4 Note: With respect to PowerShell-internal use of exit codes, this answer is focused on directly calling external (console, i.e. terminal-based) programs (which situationally requires the & operator for syntactic reasons), which is the typical use case. External programs can also be called via the Start-Process cmdlet, which, however, is … Read more

Exit codes bigger than 255 — possible?

Using wait() or waitpid() It is not possible on Unix and derivatives using POSIX functions like wait() and waitpid(). The exit status information returned consists of two 8-bit fields, one containing the exit status, and the other containing information about the cause of death (0 implying orderly exit under program control, other values indicating that … Read more

Get exit status of a process in bash

You can simply do a echo $? after executing the command/bash which will output the exit code of the program. Every command returns an exit status (sometimes referred to as a return status or exit code). A successful command returns a 0, while an unsuccessful one returns a non-zero value that usually can be interpreted … Read more

How to capture the Return Value of a ScriptBlock invoked with Powershell’s Invoke-Command

$remotesession = new-pssession -computername localhost invoke-command -ScriptBlock { cmd /c exit 2} -Session $remotesession $remotelastexitcode = invoke-command -ScriptBlock { $lastexitcode} -Session $remotesession $remotelastexitcode # will return 2 in this example Create a new session using new-pssession Invoke your scripblock in this session Fetch the lastexitcode from this session