1

I get syntax error while trying to run multiple statements within conditional if of batch script

@echo off


set COMMITTIME=%date:~-4%-%date:~-7,2%-%date:~-10,2%-%time:~-11,2%-%time:~-8,2%-%time:~-5,2%
setlocal enabledelayedexpansion
set COMMITTIME=!COMMITTIME:^ =0!
setlocal disabledelayedexpansion


if %time:~-11,2% LEQ 5 (
echo NB /b
echo Who /b
echo ok) 

echo %time:~-11,2%

if %time:~-11,2% GTR 5 (
echo Normal /b
echo menot /b
echo NOK)


::Nightly build time is less than 5 Am CET
if %time:~-11,2% LEQ 15(   
echo  ERROR commiting ec_baic /b
echo  ERROR commiting ec_baic /b
echo  ERROR commiting ec_baic)

In the batch script below first two conditional if works but the third conditional if yeids systex error

13
Normal /b
menot /b
NOK
The syntax of the command is incorrect.
1
  • I voted to close this question since the error is caused by a simple typo... Commented Jul 16, 2019 at 11:37

1 Answer 1

1

Put a rem in from of that @echo off and let the debugging begin :-)

More seriously, you'll notice one difference between the working and non-working statements, it's the space between then if condition and the opening parenthesis.

And, in fact, when I put that in, the error disappears:

rem                    +-- This is important
rem                    V
if %time:~-11,2% LEQ 15 (
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.