As know the result of ping any IP is consists of two part.The fist one is reply from .... and It is just one line and the second part which is multiple lines belongs to statistics.I want two remove second part. I just need the first line to output not statistics . Is there any command to do that?
Asked
Active
Viewed 4,613 times
0
-
2duplicate? check that: http://stackoverflow.com/questions/12319836/how-to-get-only-the-reply-line-of-ping-test-on-windows – Rebelek Sep 09 '13 at 06:42
-
@Rebelek,The question in not that but I found my answer based on your link thanks. – Mohammad Reza Rezwani Sep 09 '13 at 06:50
-
C:\>ping 127.0.0.1 | for /f "skip=3 tokens=*" %a in ('findstr Reply') do @echo %a – Mohammad Reza Rezwani Sep 09 '13 at 10:36
3 Answers
0
set "line="
for /f "delims=" %%a in ('ping 127.0.0.1 -n 1') do if not defined line set "line=%%~a"
echo %line%

Endoro
- 37,015
- 8
- 50
- 63
0
Here's an alternative.
ping www.google.com -n 1 |find /i "reply from" >> file.log
you may just want the info that this provides:
ping www.google.com -n 1 |find /i "TTL" >> file.log

foxidrive
- 40,353
- 10
- 53
- 68
0
This is an old thread but Google brought me here, so if it does for anyone else this may be helpful:
Here's one that gives a one line reply whether the ping responds or fails:
ping -n 1 127.0.0.1 | find "y "
You'll get either:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
--or--
Ping request could not find host 127.0.0.1. Please check the name and try again.
The "-n 1" limits the ping process to just 1 ping and the find "y " is used since the letter "y" and a space is common to both responses - in the words "Reply " and "try ".