Usually, when pinging a server IP address we have this in return:
Pinging with 32 bytes of data:
Reply from : bytes=32 time=151 TTL
It's pretty simple from within batch, but from command line... ugly is major understatement:
(for /f "skip=1 delims=" %F in ('ping -n 1 localhost') do @if not defined _A @echo %F&set _A=0) &set "_A="
But it does the trick, prints second line (whatever it will happen to contain) and skips the rest. You may change line it prints changing skip=
.
If you have powershell available, you could simply do: (yes I know it's not how pinging is supposed to be done in PS): powershell "ping -n 1 localhost | select -index 2"
. You may need to play with index, as on my (XP) laptop ping inserts addtional CR in each line, which has an effect of double - spacing output from PS.