使用Eggdrop&;读取活动日志文件的最后一行。tcl

使用Eggdrop&;读取活动日志文件的最后一行。tcl,tcl,eggdrop,Tcl,Eggdrop,您好,我想知道是否可以使用eggdrop和.tcl脚本读取实时日志文件的最后一行我可以读取日志文件的第一部分,但它不再读取它了是否可以对日志文件的一行长度设置上限?如果是这样,很容易得到最后一行: # A nice fat upper bound! set upperBoundLength 1024 # Open the log file set f [open $logfile r] # Go to some distance from the end; catch because don'

您好,我想知道是否可以使用eggdrop和.tcl脚本读取实时日志文件的最后一行我可以读取日志文件的第一部分,但它不再读取它了

是否可以对日志文件的一行长度设置上限?如果是这样,很容易得到最后一行:

# A nice fat upper bound!
set upperBoundLength 1024

# Open the log file
set f [open $logfile r]
# Go to some distance from the end; catch because don't care about errors here
catch {seek $f -$upperBoundLength end}
# Read to end, stripping trailing newline
set data [read -nonewline $f]
# Hygiene: close the logfile
close $f
# Get the last line
set lastline [lindex [split $data "\n"] end]

请注意,实际上并不需要执行
搜索
;它可以让您不必阅读您可能不想要的绝大多数文件。

我非常欣赏这一点,我是否需要在脚本中添加更多内容,或者只是把它放进去就可以了。我进入tcl和eggdrop大约一个星期了,但仍然不能让任何事情起作用。。再次感谢似乎我终于明白了呵呵非常感谢你的帮助