I am collecting data from the API using the wget DOS port to generate data for a log file (which will be analyzed later). The API provides all the information I need, except for the current time (it provides time at the beginning of the data stream, but not after that).
The API typically provides 10 lines of data, and then a line every 20-30 seconds.
I'm trying to make a timestamp for this output and copy it to a log file - I don't mind if the timestamp is on the same line as the rest of the output or the line before.
First, I started with this batch file:
addtimes.bat:
@echo off >nul :start set /p input="": echo %time% echo %input% goto:start
(called "wget โโ..... | addtimes.bat> log.log")
However, this led to data loss: the beginning of many lines of data was lost.
I looked over here and realized that I should use a for loop.
addtimes2.bat:
@echo off cls setlocal EnableDelayedExpansion for /F "tokens=*" %%a in ('more') do ( echo !time! %%a ) )
I tried with and without Enabled Delayed Expansion.
It seems I canโt transfer information one line at a time with a different timestamp - all my lines get the same timestamps when I close the data stream.
Typical input data are:
[1,"219","265",14528,1359031137000,1359031137000] [1,"6594","358",18188,1359031019000,1359031019000] [1,"690","94",15920,1359031534000,1359031534000] [1,"25164","102",2129,1359031457000,1359031457000] [1,"3488","329",2109,1359030868000,1359030868000] [1,"37247","6",11506,1359031223000,1359031223000]
You may notice that the data has UTC time, but this is not the current time.