Posted to tcl by aspect at Sun May 31 03:25:08 GMT 2015view raw
- #!/usr/bin/tclsh
- proc multitail {args} {
- foreach fn $args {
- set chan [open "|tail -f $fn" r]
- fconfigure $chan -blocking 0
- fileevent $chan readable [list readable $fn $chan]
- }
- }
- proc readable {fn chan} {
- if {[gets $chan line] <= 0} {
- if {[eof $chan]} {
- puts "EOF on $fn"
- close $chan
- }
- } else {
- puts "$fn:$line"
- }
- }
- exec touch a.txt b.txt
- multitail a.txt b.txt
- vwait forever