I'm trying to go around the loop a fixed number of times, however I find I cannot seem to make this statement work with

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)

Why do I get the following issue?

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

Is my formatting correct?

有帮助吗?

解决方案

Remove the spaces, and use double percent signs around your loop variable:

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%)

其他提示

in batch files you must use double percentsigns for the for-variables:

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

(also you missed a % with your variable %mycores%)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top