本帖最后由 flyinnet9 于 2015-7-11 18:28 编辑
- @echo off
- chcp 437
- setlocal enabledelayedexpansion
- for /l %%a in (1,1,254) do (
- ping 10.7.1.%%a >pinglog.txt
- For /f "skip=2 tokens=4 delims=: " %%i In ('find "statistics" pinglog.txt') Do set IP=%%i
- For /f "skip=2 tokens=4,7,11 delims=,( " %%j In ('find "Lost" pinglog.txt') Do set Sent=%%j&set Received=%%k&set Lost=%%l
- For /f "skip=2 tokens=3,6,9 delims=, " %%m In ('find "Average" pinglog.txt') Do set Minimum=%%m&set Maximum=%%n&set Average=%%o
- For /f "tokens=3" %%y in ('find /c "Request timed out" pinglog.txt') do set Count=%%y
- if !Count! neq 0 echo TIME OUT IPAddress=!IP! Sent=!Sent! Received=!Received! Lost=!Lost! Minimum=!Minimum! Maximum=!Maximum! Average=!Average>>d:\123.txt
- findstr /c:"Destination host unreachable" pinglog.txt && echo Unreachable IPAddress=!IP! Sent=!Sent! Received=!Received! Lost=!Lost!>>d:\123.txt
- )
- del /q pinglog.txt
复制代码
|