Posted to tcl by kostix at Sat Feb 02 00:44:33 GMT 2008view pretty
grid rowconfigure . 0 -weight 1 grid columnconfigure . 1 -weight 1 grid [text .log] -columnspan 3 -sticky news grid [label .l -text Command:] -row 1 -column 0 -sticky we grid [entry .cmd -textvar cmd] -row 1 -column 1 -sticky we grid [button .exec -text Go! -command go] -row 1 -column 2 -sticky we bind .cmd <Return> go switch -- $tcl_platform(platform) { unix { if {[info exists env(SHELL)]} { set shell $env(SHELL) } else { set shell /bin/sh } } windows { if {[info exists env(COMSPEC)]} { set shell $env(COMSPEC) } else { set cmd.exe } } default { return -code error "Freaky platform" } } set fd [open [list | $shell] w+] fconfigure $fd -blocking no -buffering line fileevent $fd readable get proc get {} { variable fd if {[gets $fd line] < 0} { close $fd .log insert end "SHELL quit" } else { .log insert end $line } } proc go {} { variable cmd variable fd puts $fd $cmd } vwait forever