【问题标题】:Ping Test Batch File to Text Output of ResultsPing 测试批处理文件到结果的文本输出
【发布时间】:2015-08-19 13:41:14
【问题描述】:

我编写了一个非常简单的 .bat 文件,它在启动时 ping 6 个 IP 地址,然后暂停窗口,这样我就可以检查并确保每个 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”之类的内容。

我不确定这是否可以通过一个简单的批处理文件实现,但如果不能,任何人都可以为我指出另一种语言的正确方向吗?

【问题讨论】:

    标签: batch-file cmd scripting ping


    【解决方案1】:
    set "servername=www.google.com"
    ping %servername% |find "TTL" >nul && echo %servername% is online || echo %servername% is offline
    

    你可能想玩pings 参数/n/w

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-09
      • 2015-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-29
      相关资源
      最近更新 更多