中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-25 23:43
47,812 topics / 349,910 posts / today 0 new / 48,264 members
DOS批处理 & 脚本技术(批处理室) » [Help] Jump to different statements based on the last three digits of the IP address.
Printable Version  2,250 / 5
Floor1 cldiyer Posted 2006-11-11 16:13
初级用户 Posts 8 Credits 20
c:
cd \
if exist ipconfig.txt del ipconfig.txt
ipconfig /all >ipconfig.txt
if exist ip.txt del ip.txt
find "IP Address" ipconfig.txt >ip.txt
for /f "skip=2 tokens=15" %%I in (ip.txt) do set mac=%%I

Got stuck here. The goal is to perform a jump when the IP is from 192.168.1.1 to 192.168.1.100, and another jump when it's from 192.168.1.101 to 192.168.1.238. This is for virtual disk IP shunting. The first 100 IPs connect to 192.168.1.239, and the 101st to 238th connect to 192.168.1.240. Anyone who is an expert can help...
Floor2 cldiyer Posted 2006-11-11 16:14
初级用户 Posts 8 Credits 20
Oh, by the way, add a verification for the start. If the F drive exists, then end. If it doesn't exist, then execute these statements...
Floor3 lxmxn Posted 2006-11-11 18:24
版主 Posts 4,938 Credits 11,386



  The above code has not been fully tested. If there are any problems, please follow up and continue discussing...


[ Last edited by lxmxn on 2006-11-11 at 06:28 PM ]
Floor4 cldiyer Posted 2006-11-12 01:29
初级用户 Posts 8 Credits 20
Thanks, indeed an expert... I want to ask:
:ai
if %4 leq 100 goto a
if %4 leq 238 goto b
echo No host connected......
pause&&goto :EOF
Here it's 1-100, 101 to 238. What does lep mean... If it's less than or equal to, then B would include A? Noob... Know very little about bat...
Floor5 cldiyer Posted 2006-11-12 01:37
初级用户 Posts 8 Credits 20
@echo off
e:
echo **********Disconnecting**********
for /l %%a in (1,1,10) do (
iscsicli sessionlist>session.isc
for /f "tokens=1,3,4" %%b in (session.isc) do (
if %%b==Session (
iscsicli logouttarget 0x%%d>session.isc
)
if %%b==Total (
if %%c==0 (
echo **********Disconnection successful**********
goto end
)
)
)
)
echo off

:end
echo **********Connecting to server to update game, please wait**********
iscsicli AddTargetPortal 192.168.1.240 3260
iscsicli LoginTarget iqn.2005-02.com.ricecake.iscsi:00 T * * * * * * * * * * * * * * * 0
\\gameshell\up$\Call Program\Original Call.exe

This is my iSCSI connection script. The last line is to call the Xunsan game menu after connection...
The server has two IPs, one is 239 and the other is 240. I want to use 239 for numbers 1-100 and 240 for 101-238 for IP sharding, but I don't know how to do it...
Floor6 cldiyer Posted 2006-11-12 04:16
初级用户 Posts 8 Credits 20
echo off&&setlocal ENABLEDELAYEDEXPANSION
if exist F:\ goto :EOF
for /f "delims=: tokens=2" %%a in ('ipconfig /all ^| find /i "IP Address"') do (
set ip=%%a&&set ip=!ip:.= !
call :ai !ip!
)
goto :EOF

:ai
if %4 leq 100 goto a
if %4 geq 101 goto b
echo No host is connected......
pause&&goto :EOF

:a
echo **********Connecting to update game 239, please wait**********
iscsicli AddTargetPortal 192.168.1.239 3260
for /f "delims=" %%i in ('iscsicli LoginTarget iqn.2005-02.com.ricecake.iscsi:00 T * * * * * * * * * * * * * * * 0 ^| find "Status: Successful"') do (
if "%%i" neq "" (
\\gameshell\up$\Call Program\Original Call.exe
)
)
goto :EOF

:b
echo **********Connecting to update game 240, please wait**********
iscsicli AddTargetPortal 192.168.1.240 3260
for /f "delims=" %%i in ('iscsicli LoginTarget iqn.2005-02.com.ricecake.iscsi:00 T * * * * * * * * * * * * * * * 0 ^| find "Status: Successful"') do (
if "%%i" neq "" (
\\gameshell\up$\Call Program\Original Call.exe
)
)
goto :EOF

Done... Ask, how to process the next command after the previous command is completed? I want to wait for the ISCSI connection to finish before connecting to Xunsan. This bat is transferred by a vbs.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023