Posted to tcl by kevin_walzer at Thu Oct 17 14:03:48 GMT 2013view raw

  1. set script "$portpath $verboselevel selfupdate > [file join $::env(TMPDIR) portauthority.txt] 2>&1 &"
  2.  
  3. set scripterr {
  4. AppleScript execute "
  5.  
  6. do shell script \"$script\" with administrator privileges
  7.  
  8. "
  9. }
  10.  
  11. if {[catch $scripterr errmsg]} {endProgress; tk_messageBox -icon warning -parent . -message "Error" -detail "The following output was returned: $errmsg"; return}
  12.  
  13. # set fd [open "|tail -f [file join $::env(TMPDIR) portauthority.txt]" r]
  14. set fd [open [file join $::env(TMPDIR) portauthority.txt] r]
  15. puts "reading file"
  16.  
  17. fconfigure $fd -blocking 0 -buffering none
  18. fileevent $fd readable [list logging_command $fd]
  19. vwait done
  20. set status "Done"
  21.  
  22. #process to log items in text display
  23. proc logging_command {fd} {
  24.  
  25. global log
  26. global done
  27. global pipe
  28.  
  29. set pipe $fd
  30.  
  31. #using catch for the case that the file somehow is already closed
  32. if {[catch {set isclosed [eof $fd]}] || $isclosed} {
  33. catch {close $fd}
  34. set done 1
  35. return
  36. }
  37.  
  38. #using catch for the case that the file somehow is already closed
  39. #if the pipe is closed, gets will produce an error!!!
  40. if {[catch {set data [read $fd]}]} {
  41. catch {close $fd}
  42. set done 1
  43. return
  44. }
  45.  
  46. urltext::inserttext $data\n
  47.  
  48. }