I am writing scripts to automate the ear deployment to websphere and to create variables on the app.
My problem is that manageprofiles and startserver bat files exits my batch and to go to the next step I have to invoke it multiple times
Here is my script
FOR /F "tokens=*" %%i in ('type params.properties') do SET %%i
REM SET PATH=%PATH%;%AppServerPath%\bin
REM CALL setupCmdLine.bat -create -profileName %profile% -profilePath "%AppServerPath%\profiles\%profile%" -templatePath "%AppServerPath%\profileTemplates\default"
"%AppServerPath%\bin\manageprofiles" -listProfiles | findstr -i %profile% > nul:
if %ERRORLEVEL%==1 (
ECHO Creating profile %profile% on %AppServerPath%\profiles\%profile%
"%AppServerPath%\bin\manageprofiles" -create -profileName %profile% -profilePath "%AppServerPath%\profiles\%profile%" -templatePath "%AppServerPath%\profileTemplates\default"
)
ECHO Getting profile path
FOR /F "delims=" %%a IN ('manageprofiles -getPath -profileName %profile%') DO @SET PROFILEPATH=%%a
REM SET PATH=%OLD_PATH%;%PROFILEPATH%\bin
FOR /F "tokens=7 delims= " %%H IN ('serverStatus server1 ^| findstr "Application Server"') DO (
IF /I "%%H" NEQ "STARTED" (
v ECHO Starting server1
startServer server1
)
)
"%PROFILEPATH%\bin\wsadmin" -lang jython -f EEDeployer.jy "%PROFILEPATH%"
Any ideas or alternatives to check for a profile and create it if not exists then start server1 on it?
You need to CALL
a batch to allow processing to return to the main batch.
If you simply execute a batch from within a batch, control is transferred, but no return is recorded.
CALL "%AppServerPath%\bin\manageprofiles" ...
should solve your problem. repeat with startserver...