我写了一个非常简单的.bat文件,在启动时ping了6个IP地址,然后暂停窗口,这样我就可以通过并确保每个人都在响应。
我想知道是否可以创建一个简化结果的输出.txt文件。而不是像:
这样的输出Pinging www.google.com [74.125.226.17] with 32 bytes of data:
Reply from 74.125.226.17: bytes=32 time=9ms TTL=51
Reply from 74.125.226.17: bytes=32 time=9ms TTL=51
Reply from 74.125.226.17: bytes=32 time=9ms TTL=51
Reply from 74.125.226.17: bytes=32 time=9ms TTL=51
Ping statistics for 74.125.226.17:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 9ms, Maximum = 9ms, Average = 9ms
在.txt文件中,当报告数据包丢失时,它只会读取“%servername%is online and responsive”或“%servername%is not responsive”。
我不确定这是否可以使用简单的批处理文件,但如果没有,是否有人能指出我正确的另一种语言方向?
答案 0 :(得分:1)
set "servername=www.google.com"
ping %servername% |find "TTL" >nul && echo %servername% is online || echo %servername% is offline
您可能希望使用ping
参数/n
和/w