循环的批量变量连接

时间:2016-10-14 19:59:12

标签: batch-file variables for-loop cmd

我正在尝试创建一个for循环,它会输出一定范围的响应。

使用以下工作正常:

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

输出:

NODE01: {     “123.123.123.100”:“ENABLED” }

NODE02: {     “123.123.123.200”:“启用” }

Node03: {     “123.123.123.300”:“ENABLED” }

我现在正在尝试创建一个检查节点列表的for循环:

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

上面的方法列出了Node1 IP最多七次,如何让它循环通过节点列表?我很清楚%% C但在这种情况下我根本不知道如何应用它。

1 个答案:

答案 0 :(得分:1)

启用heartbeatService.$inject = [ '$rootScope', 'vcapChanService', 'eventService', 'logger' ]; function heartbeatService( $rootScope, vcapChanService, eventService, logger ) { //.... } 并使用delayedexpansion

!node%%C!