0

I'm trying to create a for loop, that outputs a certain range of responses.

Using the following works fine:

echo Node1:
dashd-cli masternodelist status 123.123.123.100
echo.
echo Node2:
dashd-cli masternodelist status 123.123.123.200
echo.
echo Node3:
dashd-cli masternodelist status 123.123.123.300

OUTPUT:

Node01: { "123.123.123.100" : "ENABLED" }

Node02: { "123.123.123.200" : "ENABLED" }

Node03: { "123.123.123.300" : "ENABLED" }

I'm now trying to create a for loop that checks through a list of nodes:

cls
@echo off
set nodeCount=7
set Node1="111.111.111.111:1111"
set Node2="222.222.222.222:2222"
set Node3="333.333.333.333:3333"
set Node4="444.444.444.444:4444"
set Node5="555.555.555.555:5555"
set Node6="666.666.666.666:6666"
set Node7="777.777.777.777:7777"

for /L %%C in (1,1,%nodeCount%) do (
echo Node%%C:
dashd-cli masternodelist status %Node1%
)

The above method lists the Node1 IP up to seven times, how can I make it loop through the list of nodes? I'm well aware of the %%C but I simply don't know how to apply it in this case.

1 Answer 1

1

Enable the delayedexpansion and use !node%%C!:

cls
@echo off
setlocal enabledelayedexpansion
set nodeCount=7
set Node1="111.111.111.111:1111"
set Node2="222.222.222.222:2222"
set Node3="333.333.333.333:3333"
set Node4="444.444.444.444:4444"
set Node5="555.555.555.555:5555"
set Node6="666.666.666.666:6666"
set Node7="777.777.777.777:7777"

for /L %%C in (1,1,%nodeCount%) do (
echo Node%%C:
dashd-cli masternodelist status !Node%%C!
)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, that did it!

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.