Is there a standard set of return code for Windows shell scripts (* .bat files)? I am looking for something similar to Linux exit codes, where 0 == success and non-zero == failure. I need a way to programmatically check if my shell script has completed at runtime.
The most common is that sames is a Unix standard, so the return code (also called errorlevel in batch files) 0 is successful, while anything above 0 is an error.
There are a number of related issues to look for - look at this guide:
Batch Files - Error Levels
0 non-0 Windows. ERRORLEVEL, , .
if errorlevel 1 goto failure
, , .bat .
.
IF :
IF [NOT] ERRORLEVEL number command ERRORLEVEL number Specifies a true condition if the last program run returned an exit code equal to or greater than the number specified.
, Windows 0 ( ERRORLEVEL), Linux. , "", script .
0
script, , , script EXIT /B ##, , ##.
EXIT /B ##
##
I prefer this method:
[run an exe here] IF %errorlevel% NEQ 0 ( CALL :SSH_fail filename.sh %errorlevel% ) :SSH_fail Email.exe "%mailTo%" "%mailProgram% - SSH Failure " "Body: errorlevel:%~2 file name: %~1" goto cont
that way I know exactly what the error rate is. I think there can be up to 250 errors.
Source: https://habr.com/ru/post/1735461/More articles:How to drop an oracle user starting with a colon (:) - oracleHow to link and manage data in a GridView using MVP - asp.netImplementing win service in configuration - c #Store tooltip inside browser window? (without using plugins) - jqueryChange font lock color in SMerge mode - emacsopenrasta xml request returns as json - jsonWhy wasn't my HEAD the last file clicked in my main git branch? - gitValidate form with Javascript using onsubmit - javascriptWhat does it mean that an application must comply with FIPS 140? - .netProlog - Announcing Arithmetic Articles - mathAll Articles