Posted to tcl by zmoment at Wed May 10 18:29:26 GMT 2023view pretty
#!/bin/sh # the next line restarts using tclsh \ exec tclsh "$0" ${1+"$@"} proc receive {fd host} { if {[eof $fd]} { chan configure $fd -blocking 1 if {[catch {close $fd} err info]} { puts "$host :::: [dict get $info -errorcode]" } incr ::pipe_exit } elseif {[gets $fd line] >= 0} { #puts "$host: $line" } } set pipe_exit 0 set hostnames [list devuan alpine 192.168.1.253] foreach host $hostnames { set pipe [open |[list ping -W 3 -c 1 $host]] chan configure $pipe -blocking 0 chan event $pipe readable [list receive $pipe $host] } while {$pipe_exit < [llength $hostnames]} { vwait pipe_exit }