سؤال

I want to use for example:

ping google.com -t

Antwort von 193.99.144.80: Bytes=32 Zeit=17ms TTL=244

and want to save only the ms in a textfile.

How can i do that?

هل كانت مفيدة؟

المحلول

This uses a helper batch file called repl.bat - download from: https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat

Place repl.bat in the same folder as the batch file or in a folder that is on the path.

@echo off
set ip=www.google.com
ping %ip% -t |repl ".*?=.*?=([0-9]*).*TTL=.*" "$1" A >>textfile.txt

نصائح أخرى

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%

take your pick of what format you want...

If you want the result from the final line (average is the 6th item in English) then use tokens=6 and remove the ^find /i "Antwort"

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top