xferlog format: day-of-week(3) name-of-month(3) day-of-month(2) hour(2):minute(2):second(2) year(4) duration-in-seconds(rounded to nearest) hostname(or ip or "[hidden]" if Hide_Xfer_Host enabled) size-in-bytes filename(TRICKY!) encoding(b or a) "_" direction(o or i) "r" username "ftp 1" ident "l"
To grab the date use [clock scan -format] if you can find a -format that works. Else just use the [scan] tcl command which works like sscanf from C to grab the fields and put them into an order that [clock scan] likes better with [format]. Care must be taken with the xferlog entries from the filename on so use [lrange line end-9 end] or something to grab the tail end of the line and parse that apart if needed.
Now you have the filename to deal with. I'd start with using lreplace to chop off the front, then use lreplace with the end qualifiers to strip off the end and what's left should be the filename. The reason you need to be careful is the filename can contains spaces, brackets, curly-braces, etc and thus you can't trust TCL to think it's a single entry in the list. That may work, but I'd want to test it a bunch including things like multiple spaces in a row. If that trips it up you can [lrange] the front/end of the list, then use [string] to get their lengths and use some math and [string] to extract the filename or chop chars from it as needed such that TCL never interprets the filename as a list. I know that works, but not sure if you need to do that or not...
|