Posted to tcl by bicepjai at Wed Jun 16 01:59:17 GMT 2010view raw

  1. fileevent stdin readable [list data stdin]
  2. fconfigure stdin -blocking 0
  3. fconfigure stdout -buffering line
  4.  
  5. proc data {fd} {
  6. if {[eof $fd]} {
  7. exit
  8. } elseif {[gets $fd line]} {
  9. puts "$line"
  10. if {$line eq "quit"} {
  11. exit
  12. } elseif {$line eq "pause"} {
  13. set ::counter 0
  14. } elseif {$line eq "resume"} {
  15. set ::counter 0
  16. }
  17. }
  18. }
  19.  
  20. proc output { } {
  21. puts "starting"
  22. set sendMe [ exec -- dir]
  23. puts $sendMe
  24. after 1000 output
  25. }
  26.  
  27. output
  28. vwait forever