Display time and date on each command prompt line
Solved
Nyando59
Posted messages
13
Status
Member
-
dubcek Posted messages 18627 Registration date Status Contributor Last intervention -
dubcek Posted messages 18627 Registration date Status Contributor Last intervention -
Hello,
Having not found the answer to my question, I'm asking it here: I have ping issues and I'd like to see if my problems occur at fixed times. The only software I found that can ping for several days with date and time costs a pretty 40 euros, so I'd like to use the Windows command prompt instead.
I've tried: Ping -t www.google.com >> text.txt
It records each line in the text file, I want that but with the date and time. It can't be that hard é_è
Also, if anyone has software that could help me, I'm open to suggestions too =)
Having not found the answer to my question, I'm asking it here: I have ping issues and I'd like to see if my problems occur at fixed times. The only software I found that can ping for several days with date and time costs a pretty 40 euros, so I'd like to use the Windows command prompt instead.
I've tried: Ping -t www.google.com >> text.txt
It records each line in the text file, I want that but with the date and time. It can't be that hard é_è
Also, if anyone has software that could help me, I'm open to suggestions too =)
4 answers
-
Hello,
Try adding the lineecho %time% >> text.txt
to your loop :)
--
Everything has been said, but since no one is listening, it always needs to be repeated.-
-
Oh, my bad, I thought you had made a small script with a loop to ping at regular intervals.
In that case, I didn't quite understand the purpose of displaying the time? Since you're pinging directly, you're keeping an eye on it, right?
Otherwise, you can create a batch file (a Notepad document, and change .txt to .bat), and in it, you write:
@echo off
ping www.google.fr >> test.txt
echo %time% >> test.txt
And every time you run this file, it will ping and add the ping time to your file. -
-
Thank you :) I managed to create the bat file, put the loop in it, however, I'm getting something like this
Sending a 'ping' request to www.google.fr [173.194.113.184] with 32 bytes of dataÿ:
Reply from 173.194.113.184ÿ: bytes=32 time=54 ms TTL=53
Reply from 173.194.113.184ÿ: bytes=32 time=51 ms TTL=52
Reply from 173.194.113.184ÿ: bytes=32 time=50 ms TTL=52
Reply from 173.194.113.184ÿ: bytes=32 time=50 ms TTL=52
Ping statistics for 173.194.113.184:
Packetsÿ: sent = 4, received = 4, lost = 0 (loss 0%),
Approximate round trip times in milliseconds:
Minimum = 50ms, Maximum = 54ms, Average = 51ms
16:29:10.40
And I would like the time to appear on each line, is it possible?
Oh and I forgot to answer your question. Actually, I want to add -t in the loop after ping, so that it doesn't stop, and have the time on each line to test for 24 or 48 hours to see at what times I have issues with my ping, to see if it's at fixed times or completely random. -
-
-
Hi,
from memory, you can modify the command prompt like we used to do in MS-DOS
if you type the following command:
PROMPT $t - $p$g
you should get what you're looking for
to return to the original prompt, just type:
PROMPT
for more clarity on the screen, you can type:
prompt $t$h$h$h - $p$g
the display of the time will be limited to hours, minutes, and seconds
$h corresponds to 1 backspace-
-
-
-
With the prompt, I can even display the time, the date, the current directory in a colored banner on the first line, and set a different background color as well as a custom command prompt... I'll need to dig up my old MS-DOS prompts.
If you clearly explain what you want, I'll let you know if it's feasible or not. -
To try to be as clear as possible, I currently have latency issues but only at certain times of the day. I would like to know when exactly, so what I'm trying to do is run ping tests, with the time for each ping, that saves it to a text file, so I can read it back and see at what times my ping goes up or down.
-
-
Thank you very much for your answers, I would never have found that on my own. I have the format I wanted, I'm marking the post as resolved :)
-
Another method to display the time at the beginning of the line
C:> type cc.bat @echo off setlocal enableDelayedExpansion for /L %%a in (1,1,10) do ( set t=!time! for /F "delims=" %%b in ('ping -n 1 www.google.fr ^| find "TTL"') do echo !t! %%b ping -n 1 127.0.0.1 >NUL ) C:> cc 11:21:05,21 Reply from 74.125.232.151: bytes=32 time=61 ms TTL=52 11:21:05,67 Reply from 74.125.232.151: bytes=32 time=29 ms TTL=52 11:21:06,09 Reply from 74.125.232.151: bytes=32 time=26 ms TTL=52 11:21:06,51 Reply from 74.125.232.151: bytes=32 time=23 ms TTL=52 11:21:06,90 Reply from 74.125.232.151: bytes=32 time=27 ms TTL=52 11:21:07,31 Reply from 74.125.232.151: bytes=32 time=26 ms TTL=52 11:21:07,71 Reply from 74.125.232.151: bytes=32 time=24 ms TTL=52 11:21:08,12 Reply from 74.125.232.151: bytes=32 time=34 ms TTL=52 11:21:08,54 Reply from 74.125.232.151: bytes=32 time=23 ms TTL=52 11:21:09,00 Reply from 74.125.232.151: bytes=32 time=24 ms TTL=52