1#!../expect -- 2# -*- tcl -*- 3# Description: unbuffer stdout of a program 4# Author: Don Libes, NIST 5 6if {[string compare [lindex $argv 0] "-p"] == 0} { 7 # pipeline 8 set stty_init "-echo" 9 eval [list spawn -noecho] [lrange $argv 1 end] 10 close_on_eof -i $user_spawn_id 0 11 interact { 12 eof { 13 # flush remaining output from child 14 expect -timeout 1 -re .+ 15 return 16 } 17 } 18} else { 19 set stty_init "-opost" 20 set timeout -1 21 eval [list spawn -noecho] $argv 22 expect 23 exit [lindex [wait] 3] 24} 25