这是我的自动化脚本片段,用于从基于 vlan 的特定服务器进行映像。该脚本检查它的 IP 和它所在的 vlan,然后使用它连接到特定服务器。我的问题是我收到“如果此时意外”错误。请帮忙。
:getvlan
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| find "IPv4 Address"') do set IP=%%a
for /f "tokens=3 delims=." %%j in ('echo %IP%') do set vlan=%%j
if %vlan% GEQ 100 (if %vlan% LEQ 119 (
set servernowack=server1
set seshtype=M
) if %vlan% GEQ 130 (if %vlan% LEQ 139 (
set servernowack=server2
set seshtype=D
) if %vlan% GEQ 140 (if %vlan% LEQ 149 (
set servernowack=server3
set seshtype=D
) if %vlan% GEQ 150 (if %vlan% LEQ 159 (
set servernowack=server4
set seshtype=M
) if %vlan% GEQ 160 (if %vlan% LEQ 169 (
set servernowack=server5
set seshtype=D
) else (
goto fail
)
goto getserverip