-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I wrote a simple custom terminal program demonstrating how to work
with stdin/stdout/stdio, available on the Tcler's Wiki:
http://wiki.tcl.tk/3543 .  Right now I'm finding it to be useful on a
system at work that halfheartedly hides cmd.exe in the name of security.

Even though it works with lots of standard programs like dir and type,
it completely fails to capture the stdout/stderr of Fossil.  Whenever
I try to run Fossil, a window flashes onscreen for just a moment.

Is there any way to instead capture Fossil's stdout?

Here's the script from the Wiki, modified to use cmd.exe instead of
csh as the shell:

package require Tcl 8.6
package require Tk
set shell [list cmd.exe]
proc log {text {tags {}}} {
    .output configure -state normal
    .output insert end $text $tags
    .output configure -state disabled
    .output see end
}
ttk::entry .input
ttk::scrollbar .scroll -orient vertical -command {.output yview}
text .output -state disabled -yscrollcommand {.scroll set}
.output tag configure input -background gray
.output tag configure error -background red
pack .input -fill x -side bottom
pack .scroll -fill y -side right
pack .output -fill both -expand 1
focus .input
lassign [chan pipe] rderr wrerr
set stdio [open |[concat $shell [list 2>@ $wrerr]] a+]
foreach {chan tags} [list $stdio "" $rderr error] {
    chan configure $chan -buffering line -blocking 0
    chan event $chan readable [list apply {{chan tags} {
        log [chan read $chan] $tags
        if {[chan eof $chan]} {
            log EOF error
            .input state disabled
            chan close $chan
        }
    }} $chan $tags]
}
bind .input <Return> [list apply {{chan} {
    log [.input get]\n input
    chan puts $chan [.input get]
    .input delete 0 end
}} $stdio]

- -- 
Andy Goth | <andrew.m.goth/at/gmail/dot/com>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTveDAAAoJELtYwrrr47Y42uMIAOc6LvK6PzZQyLKWDbRNyesh
pWDHQzcV9Q0a5rpdAr5ij+5tvpaMn4Rn47DTDosIlpAQ9VYT4o34wQ1EPc06CW1r
GXddlsubLjG7ho2bfoDKfM9ofwX6LwGhdBwv6S7wsi7uGooXrqWg+ycsSF3nR3Wb
6TPKNiFU/3yaT2p7yiD0+upDNuVyNYePOzRVpEU+bhCS5rW3tazeAh6eJP+bdNZh
zPivibNJ2t1UO2Ew5mPTGWr8RFSPSaQwTYcYkjjur6D1cqC/f2rH0yKHi0FUVSCe
d+iv3oPtraxG8BztyoszHDfMfa4SU45hhryDayRvfTEcnAnfBRN83eFTBQNwHtU=
=V+tr
-----END PGP SIGNATURE-----
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to