Posted to tcl by evilotto at Wed Nov 02 22:59:33 GMT 2011view pretty

#!/usr/bin/env tclsh8.5

set fn [lindex $argv 0]
proc ctime {fn} {
    file stat $fn stat
    return $stat(ctime)
}
set ct [ctime $fn]

set f [open $fn]
seek $f 0 end
while 1 {
    after 1000
        set b [read $f]
        puts "got $b"
        if {[tell $f] > [file size $fn]} {
            puts "truncated or recreated.  Reopening"
                close $f
                set ct [ctime $fn]
                set f [open $fn]
        }
}