|
cldiyer
初级用户
 
积分 20
发帖 8
注册 2006-11-11
状态 离线
|
『楼 主』:
[求助]依据IP地址最后三位,转跳到不同语句.
使用 LLM 解释/回答一下
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
做到这里不会做了 要实现的目的就是IP为192.168.1.1到192.168.1.100执行一个转跳 192.168.1.101到192.168.1.238执行另一个转跳 是用来虚拟磁盘IP分流用的 前100位 连接192.168.1.239 后101到238连接192.168.1.240
哪个达人帮忙……
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...
|
|
2006-11-11 16:13 |
|
|
cldiyer
初级用户
 
积分 20
发帖 8
注册 2006-11-11
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
哦顺带的加一个开始用的验证 如果F盘存在则结束 如果不存在则执行这些语句……
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...
|
|
2006-11-11 16:14 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
@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
以上代码未完全测试,如有问题,请跟帖继续讨论……
Last edited by lxmxn on 2006-11-11 at 06:28 PM ]
@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 ]
|
|
2006-11-11 18:24 |
|
|
cldiyer
初级用户
 
积分 20
发帖 8
注册 2006-11-11
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
谢谢,果然是达人…… 我想问的是
:ai
if %4 leq 100 goto a
if %4 leq 238 goto b
echo 没有主机连接......
pause&&goto :EOF
这里 是1-100 101到238 lep是什么意思……如果是小于等于的话 B是不是就包括a了? 菜鸟…… 对bat知道很少的说……
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...
|
|
2006-11-12 01:29 |
|
|
cldiyer
初级用户
 
积分 20
发帖 8
注册 2006-11-11
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
@echo off
e:
echo **********正在断开连接**********
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 **********断开连接成功**********
goto end
)
)
)
)
echo off
:end
echo **********正在连接服务器更新游戏,请稍侯**********
iscsicli AddTargetPortal 192.168.1.240 3260
iscsicli LoginTarget iqn.2005-02.com.ricecake.iscsi:00 T * * * * * * * * * * * * * * * 0
\\gameshell\up$\调用程序\原调用.exe
这个是我的iscsi的连接脚本 最后一行是连接完后调用讯闪游戏菜单……
服务器有两个IP 一个是239 一个是240 想1-100号用239 101-238用240 IP分流 不会做……
@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...
|
|
2006-11-12 01:37 |
|
|
cldiyer
初级用户
 
积分 20
发帖 8
注册 2006-11-11
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
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 没有主机连接......
pause&&goto :EOF
:a
echo **********正在连接239更新游戏,请稍侯**********
iscsicli AddTargetPortal 192.168.1.239 3260
iscsicli LoginTarget iqn.2005-02.com.ricecake.iscsi:00 T * * * * * * * * * * * * * * * 0
\\gameshell\up$\调用程序\原调用.exe
goto :EOF
:b
echo **********正在连接240更新游戏,请稍侯**********
iscsicli AddTargetPortal 192.168.1.240 3260
iscsicli LoginTarget iqn.2005-02.com.ricecake.iscsi:00 T * * * * * * * * * * * * * * * 0
\\gameshell\up$\调用程序\原调用.exe
goto :EOF
搞定……问一下 如何等上一个命令处理完了后再处理下一个命令? 我想等ISCSI连接运行完毕后再连接讯闪 可以用vbs 这个bat是通过一个vbs转跳的
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.
|
|
2006-11-12 04:16 |
|