I have this log:
30-12-2022 23:24:32 : URI: p=2&pwr=0&noipcheck
30-12-2022 23:28:43 : URI: p=2&pwr=1110&noipcheck&debug
30-12-2022 23:28:51 : URI: p=2&pwr=0&noipcheck&debug
30-12-2022 23:31:57 : URI: p=2&pwr=2.200000
30-12-2022 23:50:02 : URI: p=2&pwr=0
31-12-2022 06:59:35 : URI: p=2&pwr=3
31-12-2022 07:04:35 : URI: p=2&pwr=0
31-12-2022 10:39:31 : URI: p=2&pwr=2.900000
31-12-2022 10:53:31 : URI: p=2&pwr=1507.900000
31-12-2022 10:53:36 : URI: p=2&pwr=1326.400000
31-12-2022 10:53:41 : URI: p=2&pwr=1410.200000
31-12-2022 10:53:46 : URI: p=2&pwr=2.900000
How can I now let write a script f.e.
simulate <hostname> <mydate> <starttimestamp> <endtimestamp> <logfilename>
where the date are filtered for <mydate>
<starttimestamp>
<endtimestamp>
and the URI should be called with <hostname>
.
I have problems in making the sleep
as the second line needs to be read in advanced, so that I know the time difference.
f.e. simulate https://www.xxxx.at 31-12-2022 10:00:00 10:55:00 log.txt
How can this be done in bash under unix?
It should then call https://www.xxxx.at?<URI>
but with the timedelay after the nearest <starttimestamp>
between each call according the logtimes but now.
f.e:
now:
`curl` "https://www.xxxx.at?p=2&pwr=2.900000"
`sleep` timedifference [31-12-2022 10:53:31 - 31-12-2022 10:39:31]
`curl` "https://www.xxxx.at?p=2&pwr=1507.900000"
...
`sleep` timedifference [31-12-2022 10:53:46 - 31-12-2022 10:53:41]
`curl` "https://www.xxxx.at?p=2&pwr=2.900000"
date
that can parse date/time strings and convert them to seconds? – Chris Davies Dec 31 '22 at 16:57oneliner
s are the kiss of death for legible software. Posting one and asking for help with it is like cooking a meal and putting it through a blender before asking someone to taste it for feedback. – Ed Morton Dec 31 '22 at 18:32oneliner
s. – Ed Morton Dec 31 '22 at 19:01