China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-08 15:11
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Jump to different statements based on the last three digits of the IP address. View 2,196 Replies 5
Original Poster Posted 2006-11-11 16:13 ·  中国 广西 柳州 电信
初级用户
Credits 20
Posts 8
Joined 2006-11-11 15:36
19-year member
UID 70234
Gender Male
Status Offline
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...
Floor 2 Posted 2006-11-11 16:14 ·  中国 广西 柳州 电信
初级用户
Credits 20
Posts 8
Joined 2006-11-11 15:36
19-year member
UID 70234
Gender Male
Status Offline
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...
Floor 3 Posted 2006-11-11 18:24 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline


@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 leq 238 goto b
echo 没有主机连接......
pause&&goto :EOF

:a
net use \\192.168.1.239\$c "" /u:"administrator"
pause&&goto :EOF

:b
net use \\192.168.1.240\$c "" /u:"administrator"
pause&&goto :EOF


  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 ]
Floor 4 Posted 2006-11-12 01:29 ·  中国 广西 柳州 电信
初级用户
Credits 20
Posts 8
Joined 2006-11-11 15:36
19-year member
UID 70234
Gender Male
Status Offline
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...
Floor 5 Posted 2006-11-12 01:37 ·  中国 广西 柳州 电信
初级用户
Credits 20
Posts 8
Joined 2006-11-11 15:36
19-year member
UID 70234
Gender Male
Status Offline
@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...
Floor 6 Posted 2006-11-12 04:16 ·  中国 广西 柳州 电信
初级用户
Credits 20
Posts 8
Joined 2006-11-11 15:36
19-year member
UID 70234
Gender Male
Status Offline
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.
Forum Jump: