I'm writing a batch file to read AML_handshake.txt date and compare the date with yesterday's date. If it matches and the last line=EOF then execute my java program. So far I have got bellow.
@ECHO OFF
SET CURRENTDATE=%DATE%
SET LOGFILE_DATE=%DATE:~4,2%.%DATE:~7,2%.%DATE:~10,4%
SET LOGFILE_TIME=%TIME:~0,2%.%TIME:~3,2%
SET LOGFILE="C:\Extractor\log\AML_Data_Auto-%LOGFILE_DATE%-%LOGFILE_TIME%.log"
call :Logit >> %LOGFILE%
exit /b
:Logit
set "firstLine"
for /f "tokens=*" %%A in (C:\Extractor\AML_handshake.txt) do (
If not defined firstLine set "firstLine=%%A"
set Lastline=%%A
)
REM *** FIRST CHECK ***
if "EOF" NEQ "%Lastline%" goto fail
REM *** SECOND CHECK ***
IF "%CURRENTDATE%" NEQ "%firstLine%" goto fail
exit /b
goto prog
:prog
echo Incremental Data Extraction - Started
sqlplus -s ***** @call_proc.sql
echo Incremental Data Extraction - Ended
echo Generating AML Files - Started
start "C:\Extractor" TableExtractor.exe
echo Generating AML Files - Ended
echo Process Completed
:fail
echo Initial Check Failed, Process Terminated
To do a test run, I have modified the txt file date to current date and executed the batch file, but in log file I always see "Initial Check Failed, Process Terminated".
Bellow is the text file.
01-JUN-2016
PORT_DATA|560538
NDB_AML_AA|43063
NDB_AML_LD|12878
NDB_AML_REPO|496
NDB_AML_TRAN|84596
NDB_AML_JOINT_AC|219873
NDB_AML_CUS_REL_PRTY|43
NDB_AML_BICCODE|108292
CUSTOMER_MASTER|684124
CATEGORY.MASTER|3288
DEPT.MASTER|2527
COUNTRY.MASTER|251
CUSTOMER.STATUS.MASTER|26
INDUSTRY.MASTER|65
JOB.TITLE.MASTER|22
COMPANY.MASTER|121
TRANSACTION.MASTER|3133
RELATION.MASTER|56
NDB_AML_TBILL_TBOND|2845
EOF
Two things I want to know.
1) How to compare the text file date with date-1(yesterday's date), 2) Why is my batch file not running even though I edit the text file date?