END [exitcode] -- reading the program exit or error code
Posted: Sun Oct 09, 2016 12:39 am
cos i couldnt find an existing example and was wondering
EXITWITHCODE.PB - PB app that exits with an error code
The following three demos simply execute the above app and read/display its error code...
GETEXITCODE.PB - PB app that runs a program and reads its error code
GETEXITCODE.BAT - Windows batch file that runs a program and reads its error code
GETEXITCODE.SH - Linux & Mac bash script that runs a program and reads its error code
EXITWITHCODE.PB - PB app that exits with an error code
Code: Select all
#ERRCODE = 123
OpenConsole()
PrintN("Exiting with error code " + Str(#ERRCODE))
End #ERRCODE
GETEXITCODE.PB - PB app that runs a program and reads its error code
Code: Select all
OpenConsole()
hRunApp = RunProgram("exitcode.exe", "", "", #PB_Program_Wait | #PB_Program_Open)
PrintN("The program exited with code " + Str(ProgramExitCode(hRunApp))): Input()
Code: Select all
exitcode.exe
@echo The program exited with code %errorlevel%
Code: Select all
#!/bin/bash
./exitcode
echo "The program exited with code $?"