我使用以下命令
ping -t 8.8.8.8
要从8.8.8.8获得连续的输出回复,就像这样
Reply from 8.8.8.8: bytes=32 time=7ms TTL=53
Reply from 8.8.8.8: bytes=32 time=3ms TTL=53
Reply from 8.8.8.8: bytes=32 time=7ms TTL=53
Reply from 8.8.8.8: bytes=32 time=4ms TTL=53
Reply from 8.8.8.8: bytes=32 time=7ms TTL=53
Reply from 8.8.8.8: bytes=32 time=5ms TTL=53
Reply from 8.8.8.8: bytes=32 time=7ms TTL=53
Reply from 8.8.8.8: bytes=32 time=2ms TTL=53
Reply from 8.8.8.8: bytes=32 time=7ms TTL=53
我的问题是我该如何在运行中或在bat文件中的特殊代码中执行特殊命令,以便为我提供time = xxms这样的连续输出
time=7ms
time=3ms
time=7ms
time=4ms
time=7ms
time=5ms
time=7ms
time=2ms
time=7ms
答案 0 :(得分:1)
Windows 10 64位。
连续输出ping延迟。
Ctrl + C断开循环。
脚本:
@rem Continuous output of ping latency.
@rem Windows 10 64-bit.
@echo off
@setlocal enableextensions
echo.
echo Ctrl+C to break loop.
echo.
:59240034
for /f "tokens=5" %%a in ('ping -n 2 8.8.8.8 ^| findstr /i "time="') do echo %%a
goto :59240034
exit /b
OR:
@rem Continuous output of ping latency.
@rem Windows 10 64-bit.
@echo off
@setlocal enableextensions
echo.
echo Ctrl+C to break loop.
echo.
:59240034b
for /f "tokens=5" %%a in ('ping -n 1 8.8.8.8 ^| findstr /i "time="') do echo %%a
sleep 1
goto :59240034b
exit /b
结果:
time=24ms
time=22ms
time=22ms
time=24ms
time=22ms
time=23ms
time=23ms
time=27ms
time=23ms