I am trying to pass a token to a subroutine in batch script-
SET devices=host1 host2 host3
FOR /F "tokens=* delims=," %%G IN (%devices%) DO CALL :sendReq %%G
:sendReq
curl.exe http://%1:1234/service/monitor
GOTO :EOF
Problems –
The system cannot find the file host1 – is the error message not sure why.
%1 is not resolving to host1?
for /fis really meant to parse text files or commands, and parses them one whole line at a time. Look at what this produces:(i.e. each go through the loop reads one whole line, and assigns the different tokens to
%G, then%H,%I,%J, … depending on how many tokens you actually have.)You just need the simpler version of
for: