Posted to tcl by kevin_walzer at Thu Oct 17 14:03:48 GMT 2013view pretty
set script "$portpath $verboselevel selfupdate > [file join $::env(TMPDIR) portauthority.txt] 2>&1 &" set scripterr { AppleScript execute " do shell script \"$script\" with administrator privileges " } if {[catch $scripterr errmsg]} {endProgress; tk_messageBox -icon warning -parent . -message "Error" -detail "The following output was returned: $errmsg"; return} # set fd [open "|tail -f [file join $::env(TMPDIR) portauthority.txt]" r] set fd [open [file join $::env(TMPDIR) portauthority.txt] r] puts "reading file" fconfigure $fd -blocking 0 -buffering none fileevent $fd readable [list logging_command $fd] vwait done set status "Done" #process to log items in text display proc logging_command {fd} { global log global done global pipe set pipe $fd #using catch for the case that the file somehow is already closed if {[catch {set isclosed [eof $fd]}] || $isclosed} { catch {close $fd} set done 1 return } #using catch for the case that the file somehow is already closed #if the pipe is closed, gets will produce an error!!! if {[catch {set data [read $fd]}]} { catch {close $fd} set done 1 return } urltext::inserttext $data\n }