http://bbs.chinaunix.net/thread-1500656-1-1.html
unbuffer ./prog >logfile &
[waker@proxy ~]$ cat $(which unbuffer)
#!/bin/sh
# \
exec expect -- "$0" ${1+"$@"}
# Description: unbuffer stdout of a program
# Author: Don Libes, NIST
if {[string compare [lindex $argv 0] "-p"] == 0} {
# pipeline
set stty_init "-echo"
eval spawn -noecho [lrange $argv 1 end]
interact
} else {
set stty_init "-opost"
eval spawn -noecho $argv
set timeout -1
expect
}