Announcement

Collapse
No announcement yet.

adding a timestamp

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • adding a timestamp

    Could someone help me adding a time stamp associated with each ping
    request, where in the code should echo %time% be? thanks!


    Code:
    @echo off
    
    Set IPs=xxx.xx.x.xx
    
    For %%* in (%IPs%) do call:pings %%* 
    
    goto:-pings subroutine-
    
    :pings
    (Set newbox=START "%*"/MIN/LOW COLOR 72)
    %newbox%  ^&(^>"c:\%*.txt" PING.exe %* -t)
    exit /b 0
    :-pings end of subroutine-
    Last edited by Rems; 10th January 2013, 20:15. Reason: added [code] tags around the code

  • #2
    Re: adding a timestamp

    You mean like this,

    Code:
    @echo off
    
    Set IPs=192.168.xxx.xx1, 192.168.xxx.xx2
    
    For %%* in (%IPs%) do call:pings %%* 
    goto:-pings end of subroutine-
    
    :pings
    set "note=please wait.. ^(this box will close automatically when pinging is done^)"
    set "cmd=START "%*"/MIN/LOW CMD /c"
    %cmd% "COLOR 72 &time/t&echo.%note% &(echo.%date% - %time%&PING.exe %* -n 10) >c:\%*.txt"
    exit /b 0
    :-pings end of subroutine-
    /Rems
    Last edited by Rems; 10th January 2013, 21:24.

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: adding a timestamp

      Thanks for the reply, what I mean is like this, a time stamp per reply so that way I can relate quality issues with a specific latency spike.

      14:14:58.793 : Reply from 192.168.xx.xx1: bytes=32 time=19ms TTL=50
      14:14:59.794 : Reply from 192.168.xx.xx1: bytes=32 time=44ms TTL=50
      14:15:00.800 : Reply from 192.168.xx.xx1: bytes=32 time=18ms TTL=50


      currently I'm the using the below bat file with fping.exe but that is only because I couldn't figure out how to get the time stamp to work in the original code I posted.

      Code:
      @echo off
      
      Set IPs=192.168.xx.xx1, 192.168.xx.xx1, 192.168.xx.xx1, 192.168.xx.xx1
      
      For %%* in (%IPs%) do call:pings %%* 
      
      goto:-pings subroutine-
      
      :pings
      (Set newbox=START "%*"/MIN/LOW COLOR 72)
      %newbox%  ^&(^>"c:\%*.txt" Fping.exe %* -c -T)
      exit /b 0
      :-pings end of subroutine-

      Comment


      • #4
        Re: adding a timestamp

        Maybe you can try something like,
        Code:
        @echo off
        
        Set "IPs=192.168.xxx.xx1, 192.168.xxx.xx2"
        
        For %%* in (%IPs%) do call:startpings %%* 
        goto:endpings
        
        :startpings subroutine
        set "note=please wait.. ^(closing this box will end the pinging^)"
        setlocal & Set "incl=%temp%.\$%*$.cmd"
        set "cmd=START "%*"/MIN/LOW CMD.exe /c"
        > "%incl%" (
        echo.:loop
        echo.for /f "skip=3 tokens=*" %%%%* in (
        echo.   'ping.exe %* -n 1 -w 1'
        echo.   ^) do (echo.%%time%% : %%%%* ^& goto:loop^)
        )
        %cmd% "@echo off&echo.%note%&COLOR 72&(call "%incl%")>c:\ping_%*.txt"
        endlocal & exit /b 0
        :endpings
        /Rems

        This posting is provided "AS IS" with no warranties, and confers no rights.

        __________________

        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts

        Comment


        • #5
          Re: adding a timestamp

          I just get a reply like this, no ping report; just a time stamp that it was pinging but no information.


          10:05:00.54 : Ping statistics for 192.168.xx.xxx:

          Comment


          • #6
            Re: adding a timestamp

            Originally posted by marino.bv View Post
            I just get a reply like this, no ping report; just a time stamp that it was pinging but no information.


            10:05:00.54 : Ping statistics for 192.168.xx.xxx:
            You might have to adjust the "skip=value" value (try "skip=2 tokens=*" ). Depending on the Windows version I guess. What's the OS version and language?

            /Rems
            Last edited by Rems; 11th January 2013, 21:58.

            This posting is provided "AS IS" with no warranties, and confers no rights.

            __________________

            ** Remember to give credit where credit's due **
            and leave Reputation Points for meaningful posts

            Comment


            • #7
              Re: adding a timestamp

              Here you go.

              Code:
              @echo off
              setlocal
              
              set IP=192.168.1.1
              
              echo Pinging %IP%...
              
              for /l %%a in (1,1,4) do call :pingIt %IP%
              
              endlocal
              echo [Done]
              
              :pingIt
              for /f "tokens=*" %%a in ('ping -n 1 %1') do @echo %time% %%a |find "Reply from "
              goto :eof
              
              :eof
              Jay Adams, Noxigen LLC

              Comment

              Working...
              X