LINUX.ORG.RU

История изменений

Исправление MKuznetsov, (текущая версия) :

set the_end false
set pipe [ open "|shell.sh" RDWR ]
fileevent $pipe readable {
  if [ catch { set s [ gets $pipe] } msg ] {
     # shell.sh завершился
     puts stderr "final ? $msg"
     set the_end true
     return
  }
  puts $s
  incr count
  if { $count == 50 } {
     puts "ПОЛСТА"
  }
}
vwait the_end
catch {close $pipe}

Исходная версия MKuznetsov, :

set the_end false
set pipe [ open "|shell.sh" RDWR ]
fileevent $pipe readable {
  if [ catch { set s [ gets $pipe] } msg ] {
     # shell.sh завершился
     puts stderr "final ? $msg"
     set the_end true
  }
  puts $s
  incr count
  if { $count == 50 } {
     puts "ПОЛСТА"
  }
}
vwait the_end
catch {close $pipe}