Search code examples
batch-fileautomationwebsphereexit-code

wsadmin jython script exit code to calling script


I am writing batch and bash scripts to automate some websphere tasks.

I need to get the exit code of myscipt.jy back to the calling script, jython script

#----------myscipt.jy-----------
#I am testing exit status
import sys;
sys.exit(1)

and the batch script is

REM superduper.cmd
profiles\myprofile\bin\wsadmin -lang jython -f myscript.jy
echo myscript.jy exited with %ERRORLEVEL%

Any ideas?


Solution

  • I am using the following workaround to get around the problem

    First write a key/value pair to a file from jython

    #----------myscipt.jy-----------
    #I am testing exit status
    import sys;
    logFile = open(heaplog, "w")
    logFile.write("HEAPSIZECHANGED=1")
    logFile.close()
    sys.exit(1)
    

    and then load the key/value as env. variable in batch and use it

    FOR /F "tokens=*" %%i in ('type "%HEAPLOG%" ^| findstr /V /B #') DO SET %%i
    IF !HEAPSIZECHANGED! EQU 1 CALL :_restartServer