Sue Huse wrote:
> I am trying to write a tcltk script that finds the nearest site
> and displays in a tk text widget stored text associated with the
> site.
>
> I want to use d.where as coordinate input to the script, but I'm
> having a difficult time redirecting the stderr. It seems thathave yout tried piping the output through sed?
> stdout is just the coordinate pairs, which I want. The stderr
> includes the mouse button instructions, etc. Tcltk chokes on
> the stderr, thinking that in fact there has been an error.some of the GRASS commands exit with a non zero status...
TCL picks this up as an error and directs the output into
an error message.
Yes, this is what happens.
You may have to run this in a shellscript that sets the exit
status to zero when done.
You should also be able to use the Tcl "catch" command to catch the
output from d.where and return an exit status of zero.
Here's an example that I've used to get a point and extract out the
individual components of the response from d.where:
catch {eval {exec d.where -1}} point
set x [lindex $point 0]
set y [lindex $point 1]
set mouse_button [lindex $point 2]
This technique should work with any GRASS program that returns a
non-zero value.
- Bob
----
Robert A. Black
Principal Engineer
Calspan Corp.
Buffalo, NY 14120