::nettest
@echo off
@setlocal enabledelayedexpansion
set hostIP=www.baidu.com
:loop
set pingline=1
set ttime=%time%
if "%ttime:~0,1%" == " " ( set ttime=%time: =0% )
set /a lasttime=(%ttime:~0,1%*10+%ttime:~1,1%)*3600+(%ttime:~3,1%*10+%ttime:~4,1%)*60+(%ttime:~6,1%*10+%ttime:~7,1%)
set lasttimet=%date% %time%
for /f "delims=" %%A in ('ping -n 1 -w 250 -l 255 %hostIP%') do (
if !pingline! equ 2 (
set logline=!date! !time! "%%A"
echo !logline!
echo !logline! | find "TTL=">nul || (
set logline=!logline:"=!
echo !logline! >> nettest.err
)
)
set /a pingline+=1
)
set ttime=%time%
if "%ttime:~0,1%" == " " ( set ttime=%time: =0% )
set /a currenttime=(%ttime:~0,1%*10+%ttime:~1,1%)*3600+(%ttime:~3,1%*10+%ttime:~4,1%)*60+(%ttime:~6,1%*10+%ttime:~7,1%)
set /a delaytime=%currenttime%-%lasttime%
if %delaytime% geq 3 (
set text=From %lasttimet% to %date% %time% have no acction
echo %text%
echo %text% >>nettest.err)
choice /t 1 /d y /n >nul
goto loop