Extracting time from logs using tcl, expect
I have logs with the following pattern:
1,30.10.2014,07:51:07,0,0,1,12,28,255,3,255,255,255,0,0,0;
2001,30.10.2014,07:51:07,0,0,0,300,5,0,255;
I need to extract date and time... for the first line I Do the following:
set starttime [string range $procline 2 20]
But how can I extract it if the identifier (the code before the time) is longer? I'm using expect (tcl). I tried matching the string, but maybe I'm doing something wrong. The line is already loaded as `$procline`.
I tried many different ways from other answers I've found here in the forums, but nothing really worked out for me.
Tcl:
set fields [split $procline ,]
set timestamp [join [lrange $fields 1 2]]
set time [clock scan $timestamp -format "%d.%m.%Y %T"]
Or, in one shot:
set time [clock scan [join [lrange [split $procline ,] 1 2]] -format "%d.%m.%Y %T"]