I am trying to make one batch file to read parameters from the file and pass it to ant for deployment.
I have made the below batch file:
setlocal enabledelayedexpansion
echo on
IF EXIST "D:\testfile1.txt" (
echo Do one thing
set string=
set /p string=< D:\testfile1.txt
echo value taken from file is %string
for /f "tokens=2,4,6 delims==:" %%G IN ("%string%") DO (
echo %%G %%H %%I
set env=%%G
set dom=%%H
set com=%%I
echo ENV !env!
echo DOM !dom!
echo COM !com!
cd D:\kpn_eai\EAI_FIXED\branches\kpn_eai_fixed\fixed\build\scripts
%ANT_HOME%\bin\xanteai deploy %%G %%H %%I
)
) ELSE (
echo Do another thing
)
endlocal
In testfile1.txt I have parameters in below format:
Environment=Env_Name1:Domain=Domain_Name1:Component=Component_name1
Parameters are different deployments. When I am running the above code it is giving below output
D:\>echo off
Do one thing Ant home is C:\tibco\ant\apache-ant-1.9.13
value taken from file is Environment=Env_name1:Domain=Domain_Name1:Component=Component_name1
Env_name1 Domain_Name1 Component_name1
ENV Env_name1
DOM Domain_Name1
COM Component_name1
Deployments starts after this.
The issue I am facing is when I run this code for different parameters (in testfile1.txt) the values of ENV, DOM and COM remains same regardless of any parameters read from testfile1.txt.
Can anyone help me to correct this code and let me know how can I just assign the values read from file to a variable and pass it to ant for deployment?
NOTE:- This batch file will be placed in scheduler which will check for testfile1.txt after every 5 minutes, when it finds that file deployment process gets triggered. Thus I have included if condition to check availability of file.
env/dom/comneed the exclamation marks inside a code block? This applies also to the var!string!Simply reverse your if logicIf not existand exit the batch file then, so no code block is neccessary.gotoif possible, but that's up to OP.