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   -
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 =)

4 answers

  1. arthurg95 Posted messages 2440 Registration date   Status Member Last intervention   343
     
    Hello,

    Try adding the line
    echo %time% >> text.txt 


    to your loop :)
    --
    Everything has been said, but since no one is listening, it always needs to be repeated.
    1
    1. Nyando59 Posted messages 13 Status Member
       
      Thank you for your super quick response :o However, I really don't use the command prompt often, and I don't understand how to add a line. If I press enter, the ping test starts. Is there a way to add a line?
      0
    2. arthurg95 Posted messages 2440 Registration date   Status Member Last intervention   343
       
      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.
      0
    3. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 659
       
      hello
      where to put these commands in a loop:
      @echo off for /L %%a in (1,1,1000000) do ( echo %time% ping www.google.fr )>> test.txt 
      0
    4. Nyando59 Posted messages 13 Status Member
       
      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.
      0
    5. arthurg95 Posted messages 2440 Registration date   Status Member Last intervention   343
       
      If he wants to do it continuously, then why not!
      0
  2. Miura564 Posted messages 14829 Registration date   Status Member Last intervention   1 560
     
    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
    0
    1. Nyando59 Posted messages 13 Status Member
       
      Thank you for your response :) Unfortunately, the time is displayed only on the line where I write my request =/
      0
    2. Miura564 Posted messages 14829 Registration date   Status Member Last intervention   1 560
       
      of course... where did you want your time?

      before submitting your request, type a blank line, it will update the time, and after your request, you will have the new time. with a little calculation, you'll have the time it took for the request.
      0
    3. Nyando59 Posted messages 13 Status Member
       
      Actually, I want the time between each ping, or like the time to display every minute, or something like that. I want to know at what time my ping increases and at what time it decreases.
      0
    4. Miura564 Posted messages 14829 Registration date   Status Member Last intervention   1 560
       
      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.
      0
    5. Nyando59 Posted messages 13 Status Member
       
      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.
      0
  3. Nyando59 Posted messages 13 Status Member
     
    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 :)
    0
  4. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 659
     
    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 
    -1
    1. arthurg95 Posted messages 2440 Registration date   Status Member Last intervention   343
       
      Pretty!
      0
    2. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 659
       
      thank you
      replace
      echo !t! %%b
      with
      echo !t:~0,-3! %%b
      to remove the tenths of seconds.
      0