Posted to tcl by schelte at Wed May 10 18:13:32 GMT 2023view raw

  1. foreach host $hosts {
  2. set pipe [open |[list ping -c 1 $host]]
  3. chan configure $pipe -blocking 0
  4. chan event $pipe readable [list receive $pipe $host]
  5. }
  6.  
  7. proc receive {fd host} {
  8. if {[eof $fd]} {
  9. chan configure $fd -blocking 1
  10. if {[catch {close $fd} err info]} {
  11. puts [dict get $info -errorCode]
  12. }
  13. } elseif {[gets $fd line] >= 0} {
  14. puts "$host: $line"
  15. }
  16. }
  17.  

Comments

Posted by schelte at Wed May 10 18:20:10 GMT 2023 [text] [code]

Should be "puts [dict get $info -errorcode]" (lowercase c).