[GRASS5] Re: [bug #3709] (grass) d.m - commands output pollutes the Grass terminal

Michael Barton michael.barton at asu.edu
Sat Oct 22 12:12:24 EDT 2005


Thanks Glynn. I'll try this.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
Arizona State University
Tempe, AZ 85287-2402

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton



> From: Glynn Clements <glynn at gclements.plus.com>
> Date: Sat, 22 Oct 2005 13:01:29 +0100
> To: Michael Barton <michael.barton at asu.edu>
> Cc: Paolo Cavallini via RT <grass-bugs at intevation.de>, <grass5 at grass.itc.it>
> Subject: Re: [GRASS5] Re: [bug #3709] (grass) d.m - commands output pollutes
> the Grass terminal
> 
> 
> Michael Barton wrote:
> 
>> Thanks for looking at this. Run_panel is indeed based directly on your run
>> procedure from a year or so back (part of the execute, run, spawn, and term
>> procedures you did to resolve problems in the pull-down menu system).
>> 
>> Given what you say...
>> 
>> 1) Should run_panel be eval exec -- $cmd >@ /dev/null  ?
>> 2) Should this be the case for the run procedure too?
> 
> Ideally it would use the internal log window, but redirecting to
> /dev/null is probably the next best thing.
> 
> Note that if the terminal has the TOSTOP flag set (i.e. "stty tostop"),
> a background process which tries to write to the terminal
> will be suspended, which is undesirable.
> 
> In any case, stderr has to be redirected somewhere, as exec generates
> an error if anything is written to stderr and it hasn't been
> redirected.
> 
>> I struggled over gui.tcl for many hours last weekend. I understand what it
>> is doing pretty much, but it is considerably more complicated than needed in
>> this case and I was unable to extract or create the code to redirect all
>> output to the window at the bottom of the GIS Manager.
> 
> Try the following (untested):
> 
> proc cmd_output {fh} {
> global outtext
> while {![eof $fh]} {
> set str [gets $fh]
> append str "\n"
> if { [fblocked $fh] } { set str [read $fh] }
> while {[set idx [string first "\b" $str]] != -1} {
> set last [expr $idx - 1]
> set str1 [string range $str 1 $last]
> set first [expr $idx + 1]
> set str [string range $str $first end]
> set pos [$outtext index "end - 1 chars"]
> $outtext delete $pos
> $outtext insert end $str1
> }
> $outtext insert end $str
> $outtext yview end
> update idletasks
> }
> close $fh
> }
> 
> proc run_panel {cmd} {
> global outtext
> set cmd [concat | $cmd 2>@ stdout]
> if { [catch {open $cmd r} fh] } {
> error $fh
> }
> $outtext insert end "$cmd\n"
> $outtext yview end
> cmd_output $fh
> }
> 
> This differs from the mechanism used in gui.tcl, as run_panel needs to
> wait until the command has completed before it returns.
> 
> -- 
> Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list