状况说明:
50个车站,编号为1-50,对应IP段分别为192.168.100.*--192.168.149.*
每个车站22个工作站,IP尾分别为 1,2,3,4,5,13,14,15,23,24,25,33,34,35,43,44,45,51,52,53,54,55
要求,可以对指定车站所有工作站完成PING操作,检查是否离线
代码如下:
批处理文件test.bat:- @echo off
- del /s /q *号*.txt
- ::删除历史检测文件,防止混淆
- :begin
- set /p cum="请输入站点编号(1-50):"
- set /a num=%cum%-1
- if %cum% equ 0 goto begin
- if %cum% geq 51 goto begin
- ::输入站点编号检查,如有错误重新输入
- if %cum% geq 1 if %cum% leq 10 goto nexta
- if %cum% geq 11 if %cum% leq 50 goto nextb
- :nexta
- @echo on
- for /f %%a in (ip.txt) do ping /n 1 192.168.10%num%.%%a | find "TTL" >nul && echo 192.168.10%num%.%%a >>%cum%号站点up.txt || echo 192.168.10%num%.%%a>>%cum%号站点down.txt
- goto begin
- :nextb
- @echo on
- for /f %%a in (ip.txt) do ping /n 1 192.168.1%num%.%%a | find "TTL" >nul && echo 192.168.1%num%.%%a >>%cum%号站点up.txt || echo 192.168.1%num%.%%a>>%cum%号站点down.txt
- goto begin
复制代码 新手作品,写法比较粗糙,请高手指定斧正。谢谢 |