Timestamp Ping.

  • Thread starter Thread starter BaKaR
  • Start date Start date
You want to know the time that you pinged something? Is that what you mean?

echo %time% & ping google.com

Is that what you mean?

Ray at work

BaKaR said:
Hi!

Easy way to Timestamp ping.exe, so if the ping command is: ping
www.google.com -t you get like %time% ping reply ... ?
 
Well, not exactly ..
I thought something like this:

Pinging *IP* with 32 bytes of data:

%time% Reply from *IP*: bytes=32 time=1ms TTL=128
%time% Reply from *IP*: bytes=32 time<1ms TTL=128
%time% Reply from *IP*: bytes=32 time<1ms TTL=128
%time% Reply from *IP*: bytes=32 time<1ms TTL=128

Ping statistics for *IP*
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms


I want to Prefix every ping reply with a timestamp .. not sure if that is possible without using WSH or VBScript ...


Thank You,
 
In said:
Well, not exactly ..
I thought something like this:

Pinging *IP* with 32 bytes of data:

%time% Reply from *IP*: bytes=32 time=1ms TTL=128
%time% Reply from *IP*: bytes=32 time<1ms TTL=128
%time% Reply from *IP*: bytes=32 time<1ms TTL=128
%time% Reply from *IP*: bytes=32 time<1ms TTL=128

Ping statistics for *IP*
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms


I want to Prefix every ping reply with a timestamp .. not sure if
that is possible without using WSH or VBScript ...

I don't see how it is possible at all as I think that option would need
to exist inside ping.exe.
 
Why not just timestamp the beginning? The ping request will be a second
apart unless you specified otherwise with the -w switch.

for /f "tokens=*" %%q in ('ping localhost) do (echo %time% %%q)

That would stick a timestamp in front of each line. This does not seem like
it would be fun to read or beneficial though. Perhaps if you tell us the
goal, someone can offer something better.

Ray at work


BaKaR said:
Well, not exactly ..
I thought something like this:

Pinging *IP* with 32 bytes of data:

%time% Reply from *IP*: bytes=32 time=1ms TTL=128
%time% Reply from *IP*: bytes=32 time<1ms TTL=128
%time% Reply from *IP*: bytes=32 time<1ms TTL=128
%time% Reply from *IP*: bytes=32 time<1ms TTL=128

Ping statistics for *IP*
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms


I want to Prefix every ping reply with a timestamp .. not sure if that is
possible without using WSH or VBScript ...
 
Hi Again.

Well, i need to ping -t (overnight) few nodes (30).

In the morning (or day after) i need to chk some nodes against others, so i need a timestamp for every Reply i did get, or time out.

for /f "tokens=*" %q in ('ping localhost) do (echo %time% %q) == would almost be nice, just to redirect it to a file, and rid off
the new lines .. maybe i can handle that, ill try.

Thank You,
 
BaKaR said:
Hi Again.

Well, i need to ping -t (overnight) few nodes (30).

In the morning (or day after) i need to chk some nodes against others,
so i need a timestamp for every Reply i did get, or time out.
for /f "tokens=*" %q in ('ping localhost) do (echo %time% %q) == would
almost be nice, just to redirect it to a file, and rid off the new
lines .. maybe i can handle that, ill try.
Thank You,
Not a batch solution, but my google search on "multi ping" showed
this one which has a stamped logfile:
http://www.pablovandermeer.nl/body_multi_ping.html

HTH
 
Well, i need to ping -t (overnight) few nodes (30).

In the morning (or day after) i need to chk some nodes against others, so i need a timestamp for every Reply i did get, or time out.

for /f "tokens=*" %q in ('ping localhost) do (echo %time% %q) == would almost be nice, just to redirect it to a file, and rid off
the new lines .. maybe i can handle that, ill try.

I'm too lazy to work out the syntax of CMD's "FOR /F"; I use 4NT
instead. The following command
ping localhost | FOR %fu IN (@Con) ECHO %_time "%fu"
produces this output:

11:44:27 ""
11:44:27 "Pinging 127.0.0.1 with 32 bytes of data:"
11:44:27 ""
11:44:27 "Reply from 127.0.0.1: bytes=32 time<10ms TTL=128"
11:44:28 "Reply from 127.0.0.1: bytes=32 time<10ms TTL=128"
11:44:29 "Reply from 127.0.0.1: bytes=32 time<10ms TTL=128"
11:44:30 "Reply from 127.0.0.1: bytes=32 time<10ms TTL=128"
11:44:30 ""
11:44:30 "Ping statistics for 127.0.0.1:"
11:44:30 " Packets: Sent = 4, Received = 4, Lost = 0 (0 loss),"
11:44:30 "Approximate round trip times in milli-seconds:"
11:44:30 " Minimum = 0ms, Maximum = 0ms, Average = 0ms"

The quotes are necessary to prevent the redirection symbol which happens
to occur in the output ("time<10ms") being seen by the parser.

Obviously, this output can be redirected to a file. In addition, 4NT's
LOG command will produce a log file where each command is time-stamped.
These two can be combined by redirecting the command output to the LOG
file as well.

Like most professional tools, 4NT is not free. 4NT's FOR command is
documented at <http://jpsoft.com/help/for.htm>
 
I know this is an old post but I came across it on a Google search. Since there is no real solution posted here I'll post this.

@echo off
for /f "tokens=*" %%A in ('ping localhost -n 1') do (echo %%A && GOTO Ping)
:Ping
for /f "tokens=* skip=2" %%A in ('ping localhost -n 1') do (echo %time% %%A && GOTO Ping)

It prints like the OP wanted, only pings every 4 seconds, and summary info could be added if needed.
 
Last edited:
"only pings every 4 seconds" with no reply from host else its every ~.05 seconds so you might want to put in a delay.
 
Back
Top