locked
Ping with time stamps possible? RRS feed

  • Question

  • Hello,

    I need to be able to run a batch file or copy and past a command that allows me to ping an IP but shows the time stamps is this possible?

    I did google this and tried a couple but they didn't work for example:

    @echo offecho  >pinglog.txtfor /f "tokens=*" %%A in ('ping 127.0.0.1 -n 1 ') do (echo %%A>>pinglog.txt && GOTO Ping):Pingfor /f "tokens=* skip=2" %%A in ('ping 127.0.0.1 -n 1 ') do (echo %date% %time% %%A>>pinglog.txt && GOTO Ping)

    I just want it to go to c:\pinglog.txt

    Thanks

    Monday, January 12, 2015 1:56 PM

Answers

  • Hi TB303,

    If you can use Windows Powershell, the script below can work:

    ping 192.168.21.10 -t|foreach{
    if ($_ -like "Reply*"){
    write-host "$($_) $(get-date)"}
    else{$_}
    }

    If there is anything else regarding this issue, please feel free to post back.

    Best Regards,

    Anna Wang



    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com

    • Proposed as answer by Tim CerlingMVP Monday, January 19, 2015 1:36 AM
    • Marked as answer by AnnaWY Thursday, January 22, 2015 3:02 AM
    Sunday, January 18, 2015 5:53 AM

All replies

  • How do you need it represented?  In PowerShell you could simply:

    Get-Date

    Ping <address> -n 1

    Get-Date


    . : | : . : | : . tim

    Tuesday, January 13, 2015 1:31 AM
  • It needs to be a continous ping and it needs to output like it does in a command prompt and to c:\pinglog.txt, but each line says the time and date for example:

    C:\> ping 192.168.21.10 -t

    Pinging 192.168.21.10 with 32 bytes of data:
    Reply from 192.168.21.10: bytes=32 time<1ms TTL=127 08:00:01 13/01/2015
    Reply from 192.168.21.10: bytes=32 time<1ms TTL=127 08:00:02 13/01/2015
    Reply from 192.168.21.10: bytes=32 time<1ms TTL=127 08:00:03 13/01/2015
    Reply from 192.168.21.10: bytes=32 time=1ms TTL=127 08:00:04 13/01/2015
    Reply from 192.168.21.10: bytes=32 time<1ms TTL=127 08:00:05 13/01/2015

    or similar

    Tuesday, January 13, 2015 8:02 AM
  • Hi TB303,

    If you can use Windows Powershell, the script below can work:

    ping 192.168.21.10 -t|foreach{
    if ($_ -like "Reply*"){
    write-host "$($_) $(get-date)"}
    else{$_}
    }

    If there is anything else regarding this issue, please feel free to post back.

    Best Regards,

    Anna Wang



    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com

    • Proposed as answer by Tim CerlingMVP Monday, January 19, 2015 1:36 AM
    • Marked as answer by AnnaWY Thursday, January 22, 2015 3:02 AM
    Sunday, January 18, 2015 5:53 AM