Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
#!/usr/bin/expect -- # (find-es "expect" "input-from-fifo") # (find-expcommand "spawn") # (find-expcommand "interact") # (find-expcommand "stty") # Edrx, 2004sep06 if {$argc<2} { puts "Usage: $argv0 fifoname progname \[arg \[arg ...\]\]" exit 1 } set FIFO [lindex $argv 0] set PROG [lindex $argv 1] set ARGS [lrange $argv 2 end] spawn -noecho sh -c "while \[ -r $FIFO \]; do cat $FIFO; done" stty raw < $spawn_out(slave,name) set readfifo_spawn_id $spawn_id eval spawn -noecho [list $PROG] $ARGS interact { -input $user_spawn_id -output $spawn_id -input $readfifo_spawn_id -output $spawn_id -input $spawn_id -output $user_spawn_id } exit 0 #* # Example: rm -Rv /tmp/myfifos/ mkdir /tmp/myfifos/ (cd /tmp/myfifos/ mkfifo fifo1 sleep 2; echo "pwd" > fifo1 sleep 2; echo "echo bar" > fifo1 ) & readfifo /tmp/myfifos/fifo1 bash #*