尝试在有条件的批处理脚本中运行多个语句时遇到语法错误
@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)
在下面的批处理脚本中,前两个有条件的if起作用,而第三个有条件的if systex错误
13
Normal /b
menot /b
NOK
The syntax of the command is incorrect.
答案 0 :(得分:1)
从rem
中插入@echo off
,然后开始调试:-)
更严重的是,您会发现有效语句和非有效语句之间的区别是 ,这是if
条件与左括号之间的距离。
事实上,当我把它放进去时,错误消失了:
rem +-- This is important
rem V
if %time:~-11,2% LEQ 15 (