1

我试图绕过循环固定次数,但是我发现我似乎无法使此语句与

REM @echo off
SET TotalCores=12
SET Sockets=2
SET SlaveNodes=4
SET /A mycores = %TotalCores% / %SlaveNodes%
FOR /L %i in (0,1,%SlaveNodes%) DO (call slavenode.bat  %i %mycores)

为什么我会收到以下问题?

SET /A mycores = 12 / 4
SlaveNodesi was unexpected at this time.

我的格式正确吗?

4

2 回答 2

3

删除空格,并在循环变量周围使用双百分号:

REM @echo off
SET TotalCores=12
SET Sockets=2
SET SlaveNodes=4
SET /A mycores=%TotalCores%/%SlaveNodes%
FOR /L %%i in (0,1,%SlaveNodes%) DO (call slavenode.bat  %%i %mycores%)
于 2013-10-16T16:59:20.703 回答
1

在批处理文件中,您必须对 for 变量使用双百分号:

FOR /L %%i in (0,1,%SlaveNodes%) DO (call slavenode.bat  %%i %mycores%)

(你也错过了%你的变量 %mycores% )

于 2013-10-16T16:58:35.863 回答