本帖最后由 zjpwang 于 2017-2-8 13:28 编辑
不知道为什么,比如100个ip,第一次查出80个ip通讯失败,再多80个ip进行ping,结果剩下70个ip通讯错误,似乎代码有问题,大侠帮助- @echo off&setlocal enabledelayedexpansion
-
- set line=0
- for /f %%i in (pinglist.txt) do (set /a line=line+1)
- echo IP监测点总数是:%line%
-
- set /p count=请输入文件分割份数:
- set /a size=line/count
-
- set m=0
- set n=1
-
- for /f %%i in (pinglist.txt) do (
- echo %%i>>templist-!n!.txt
- set /a m=m+1
- if !m! geq %size% (set m=0
- if !n! lss %count% (set /a n=n+1)
- )
- )
-
- echo 开始时间:!time!>log.txt
-
- for /l %%j in ( 1 1 %count% ) do (
- echo ^@echo off^&setlocal enabledelayedexpansion >ping-%%j.bat
- echo. >>ping-%%j.bat
- echo for /f %%%%i in (templist-%%j.txt^) do ( >>ping-%%j.bat
- echo ping %%%%i ^|^| if errorlevel 1 echo %%%%i通讯错误 ^>^>log.txt >>ping-%%j.bat
- echo ^) >>ping-%%j.bat
- echo. >>ping-%%j.bat
- echo echo. ^>temp-%%j.txt >>ping-%%j.bat
- echo exit >>ping-%%j.bat
- )
-
- for /l %%k in ( 1 1 %count% ) do (start ping-%%k.bat)
复制代码
|