proc position-at-end filename { set fileId [open $filename] seek $fileId 0 end return $fileId } proc sleep time { if {[info tclversion] > 7.5} { after [expr 1000 * $time] } else { # This is the only host-specific # code in this example. exec sleep $time } } ######## # # tail-f # # Copyright Cameron Laird 1996. # # This is a close emulation of what the standard # Unix tail(1) command does. # ######## proc tail-f filename { set fileId [position-at-end $filename] while 1 { gets $fileId currentLine if {{} == $currentLine} { sleep 1 } else { puts $currentLine } } } # Presumably someone has set filename in this scope. tail-f $filename