【发布时间】:2014-05-08 14:20:05
【问题描述】:
我想用例如:
ping google.com -t
Antwort von 193.99.144.80: Bytes=32 Zeit=17ms TTL=244
并且只想将 ms 保存在文本文件中。
我该怎么做?
【问题讨论】:
标签: batch-file ping
我想用例如:
ping google.com -t
Antwort von 193.99.144.80: Bytes=32 Zeit=17ms TTL=244
并且只想将 ms 保存在文本文件中。
我该怎么做?
【问题讨论】:
标签: batch-file ping
这使用了一个名为 repl.bat 的辅助批处理文件 - 从以下位置下载:https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat
将repl.bat 放在与批处理文件相同的文件夹中或路径上的文件夹中。
@echo off
set ip=www.google.com
ping %ip% -t |repl ".*?=.*?=([0-9]*).*TTL=.*" "$1" A >>textfile.txt
【讨论】:
repl.bat 到底在做什么?
TTL=的行中
for /f "tokens=7delims== " %%a in ('ping google.com^|find /i "Antwort"') do set ms=%%a
echo %ms%
set "ms=%ms:~0,-2%"
echo %ms%
选择你想要的格式...
如果您想要最后一行的结果(平均是英文的第 6 项)然后使用 tokens=6 并删除 ^find /i "Antwort"
【讨论】:
for 命令不会吐出任何内容,因为ping 命令永远不会结束。
ping 似乎没有什么意义。没有更多细节......