I'll start off by saying that I'm very new to scripting...
I'm trying to create a batch file that periodically pings a host. At the moment, I'm just testing it on my local PC. Here's what I've got so far:
@echo off
set SERVERNAME=127.0.0.1
set limit=3
ECHO %date%, %time% Starting ping test to localhost>>c:\users\%username%\desktop\Pingtest.txt
for /l %%X in (1,1,%limit%) do (
ping %servername% -n 3 | FIND "Reply" >>c:\users\%username%\desktop\Pingtest.txt
echo %time% >>c:\users\%username%\desktop\Pingtest.txt
Timeout /t 5
)
Exit
However, the timestamp always stays the same. It should show the time as being ~5 seconds after (or however long the timeout value is set), but stays the same as the first timestamp. Here's an example of the output:
25/08/2015, 2:09:18.34 Starting ping test to localhost
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
2:09:18.34
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
2:09:18.34
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
2:09:18.34
Is there any way to get it to update with the proper time?
As a side note, the "for /l %%X in..." I can't figure out what I should actually put in place of %%X. From Googling etc, I've seen people using different ones, but can't seem to figure out what it refers to. If someone could let me know about that as well, it'd be much appreciated.
Thanks