[GRASS5] nviz problem

Hi,

This is an interesting one. If I execute something like "nviz -q &", nviz
starts up normally with the wish (%) prompt. If I hit enter at the prompt I
am returned to the normal command line prompt and can run other commands
(while nviz is running). When I quit nviz I get the respone on the command
line ...
[1]+ Done nviz -q
which is what I would expect from a command that has been running in the
background.

Out of curiousity try creating a simple startup script with the following:

#!/bin/sh
exec nviz "$0" "$@"

Make it executable and try running it in the background. For example if you
name the script nv_start.sh, try "nv_start.sh elev=dem &" and see if that
works.

--
Bob

On 12/18/2004, "Huidae Cho" <grass4u@gmail.com> wrote:

Interesting!

Is wish running in background? As I know, a shell-like program cannot be
running in that way because if it's bg'ed or run with "&", /bin/sh or
the login shell takes control of stdin so that users can stay in the login
shell.

If it's executed by a script, then it's ok because it's a usual shell
script.

Do you mean running "nviz" and executing other programs in the "%" nviz
prompt instead of running "nviz &"?

If wish is running in background (wish &), how can you execute wish

functions?

Thank you.
Huidae Cho

On Sat, Dec 18, 2004 at 01:22:50PM +0000, Bob Covill wrote:

Hi,

It appears that not even wish will run in the background on your system

...

very strange.

The current nviz IS the old NVWISH executable which was called was called

by

the old nviz shell script. The reason I got rid of the shell script was

because when nviz encountered an error the same un-informitive message

was

generated because it was passed through the script. Also, there are a

number

of error catches in the actual nviz tcl scripts which were completely

ignored

with the old shell startup.

Before reverting to the old startup it would be nice to know why wish

(and

nviz) will not run in the background on some systems. On both of my

RedHat

systems it runs fine both in the background and the foreground.

--

Bob

On 12/18/2004, "Huidae Cho" <grass4u@gmail.com> wrote:

>Hi,

>

>Now nviz is not a *wish script but a shell itself. That's why it prints

>a prompt and we cannot execute it background and inside "d.m &". To fix

>this problem, I think we should go back to NVWISH because running nviz

>foreground is pain.

>

>You can test this:

>

> wish &

>

>prints % prompt and just stop!

>

>Huidae Cho

>

>

>On Fri, Dec 17, 2004 at 09:02:39PM -0400, Bob Covill wrote:

>> Hello,

>>

>> I tried running the latest version of nviz in the background with

>> various options and it seems to work fine. The "%" prompt that you see

>> is perfectly normal. The nviz program is simply a customized version

of

>> the Tcl/Tk "wish" executable. Try executing "wish" on the command line

>> and you should see the same prompt.

>>

>> As for it crashing when it is run in the background, I have no idea.

You

>> might try changing GRASS_MESSAGE_FORMAT environment variable to see if

>> that has any effect.

>>

>> It might help to know what platform and Tcl/Tk version it is failing

on.

>>

>> For me it works on RedHat 7.3 with Tk8.3, and RedHat 9 with Tk8.4.

>>

>> --

>> Bob

>>

>>

>> Helena wrote:

>> >Huidae Cho wrote:

>> >

>> >>Hi,

>> >>

>> >>I noticed today that nviz doesn't work if I run it background as

before.

>> >>Similarly, it just stops after displaying a map when it's executed

from

>> >>"d.m &" which is recommended in the welcome message.

>> >>

>> >>nviz elevation=dem & # doesn't work

>> >>d.m & # nviz doesn't work

>> >>

>> >>nviz elevation=dem # works!

>> >>d.m # nviz works!

>> >>

>> >>And I see nviz prints % prompt. Does anyone have a clue?

>> >

>> >

>> >It must be the latest change that was done - I just tried it and it

>> >does not work even if I do nviz elevation=dem, it displays the DEM

>> >but fails to open the Main pannel and prints a % prompt.

>> >It worked OK just a few days (weeks?) ago.

>> >It may be related to the change in the startup script - Bob, are you

>> >around? How does it work for you?

>> >

>> >Helena

>> >

>> >>

>> >>Thanks.

>> >>Huidae Cho

>> >>

>> >>_______________________________________________

>> >>grass5 mailing list

>> >>grass5@grass.itc.it

>> >>http://grass.itc.it/mailman/listinfo/grass5

>> >

>> >

>

>

_______________________________________________
grass5 mailing list
grass5@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass5

Hi, output is the following:

GRASS 5.7.cvs:~/tmp > cat a
#!/bin/sh
exec nviz "$0" "$@"
GRASS 5.7.cvs:~/tmp > ./a elev=dem&
[1] 1112
GRASS 5.7.cvs:~/tmp > Loading Data
Loading Data
translating colors
recalculating normals...
% w 100

[1]+ Stopped ./a elev=dem
GRASS 5.7.cvs:~/tmp >

It stops just after displaying map and empty control windows and
if I "fg", it starts working again.

I think behavior is not consistent from system to system.

Huidae Cho

On Sat, Dec 18, 2004 at 04:29:33PM +0000, Bob Covill wrote:

Hi,

This is an interesting one. If I execute something like "nviz -q &", nviz

starts up normally with the wish (%) prompt. If I hit enter at the prompt I

am returned to the normal command line prompt and can run other commands

(while nviz is running). When I quit nviz I get the respone on the command

line ...

[1]+ Done nviz -q

which is what I would expect from a command that has been running in the

background.

Out of curiousity try creating a simple startup script with the following:

#!/bin/sh

exec nviz "$0" "$@"

Make it executable and try running it in the background. For example if you

name the script nv_start.sh, try "nv_start.sh elev=dem &" and see if that

works.

--

Bob

On 12/18/2004, "Huidae Cho" <grass4u@gmail.com> wrote:

>Interesting!

>

>Is wish running in background? As I know, a shell-like program cannot be

>running in that way because if it's bg'ed or run with "&", /bin/sh or

>the login shell takes control of stdin so that users can stay in the login

>shell.

>

>If it's executed by a script, then it's ok because it's a usual shell

>script.

>

>Do you mean running "nviz" and executing other programs in the "%" nviz

>prompt instead of running "nviz &"?

>

>If wish is running in background (wish &), how can you execute wish

functions?

>

>

>Thank you.

>Huidae Cho

>

>

>On Sat, Dec 18, 2004 at 01:22:50PM +0000, Bob Covill wrote:

>>

>> Hi,

>>

>>

>>

>> It appears that not even wish will run in the background on your system

...

>>

>> very strange.

>>

>>

>>

>> The current nviz IS the old NVWISH executable which was called was called

by

>>

>> the old nviz shell script. The reason I got rid of the shell script was

>>

>> because when nviz encountered an error the same un-informitive message

was

>>

>> generated because it was passed through the script. Also, there are a

number

>>

>> of error catches in the actual nviz tcl scripts which were completely

ignored

>>

>> with the old shell startup.

>>

>>

>>

>> Before reverting to the old startup it would be nice to know why wish

(and

>>

>> nviz) will not run in the background on some systems. On both of my

RedHat

>>

>> systems it runs fine both in the background and the foreground.

>>

>>

>>

>> --

>>

>> Bob

>>

>>

>>

>> On 12/18/2004, "Huidae Cho" <grass4u@gmail.com> wrote:

>>

>>

>>

>> >Hi,

>>

>> >

>>

>> >Now nviz is not a *wish script but a shell itself. That's why it prints

>>

>> >a prompt and we cannot execute it background and inside "d.m &". To fix

>>

>> >this problem, I think we should go back to NVWISH because running nviz

>>

>> >foreground is pain.

>>

>> >

>>

>> >You can test this:

>>

>> >

>>

>> > wish &

>>

>> >

>>

>> >prints % prompt and just stop!

>>

>> >

>>

>> >Huidae Cho

>>

>> >

>>

>> >

>>

>> >On Fri, Dec 17, 2004 at 09:02:39PM -0400, Bob Covill wrote:

>>

>> >> Hello,

>>

>> >>

>>

>> >> I tried running the latest version of nviz in the background with

>>

>> >> various options and it seems to work fine. The "%" prompt that you see

>>

>> >> is perfectly normal. The nviz program is simply a customized version

of

>>

>> >> the Tcl/Tk "wish" executable. Try executing "wish" on the command line

>>

>> >> and you should see the same prompt.

>>

>> >>

>>

>> >> As for it crashing when it is run in the background, I have no idea.

You

>>

>> >> might try changing GRASS_MESSAGE_FORMAT environment variable to see if

>>

>> >> that has any effect.

>>

>> >>

>>

>> >> It might help to know what platform and Tcl/Tk version it is failing

on.

>>

>> >>

>>

>> >> For me it works on RedHat 7.3 with Tk8.3, and RedHat 9 with Tk8.4.

>>

>> >>

>>

>> >> --

>>

>> >> Bob

>>

>> >>

>>

>> >>

>>

>> >> Helena wrote:

>>

>> >> >Huidae Cho wrote:

>>

>> >> >

>>

>> >> >>Hi,

>>

>> >> >>

>>

>> >> >>I noticed today that nviz doesn't work if I run it background as

>>

>> before.

>>

>> >> >>Similarly, it just stops after displaying a map when it's executed

from

>>

>> >> >>"d.m &" which is recommended in the welcome message.

>>

>> >> >>

>>

>> >> >>nviz elevation=dem & # doesn't work

>>

>> >> >>d.m & # nviz doesn't work

>>

>> >> >>

>>

>> >> >>nviz elevation=dem # works!

>>

>> >> >>d.m # nviz works!

>>

>> >> >>

>>

>> >> >>And I see nviz prints % prompt. Does anyone have a clue?

>>

>> >> >

>>

>> >> >

>>

>> >> >It must be the latest change that was done - I just tried it and it

>>

>> >> >does not work even if I do nviz elevation=dem, it displays the DEM

>>

>> >> >but fails to open the Main pannel and prints a % prompt.

>>

>> >> >It worked OK just a few days (weeks?) ago.

>>

>> >> >It may be related to the change in the startup script - Bob, are you

>>

>> >> >around? How does it work for you?

>>

>> >> >

>>

>> >> >Helena

>>

>> >> >

>>

>> >> >>

>>

>> >> >>Thanks.

>>

>> >> >>Huidae Cho

>>

>> >> >>

>>

>> >> >>_______________________________________________

>>

>> >> >>grass5 mailing list

>>

>> >> >>grass5@grass.itc.it

>>

>> >> >>http://grass.itc.it/mailman/listinfo/grass5

>>

>> >> >

>>

>> >> >

>>

>> >

>>

>> >

>

>_______________________________________________

>grass5 mailing list

>grass5@grass.itc.it

>http://grass.itc.it/mailman/listinfo/grass5

>

>

I want to add a report that might (or I suppose might not) help to clarify
what is happening.

I am at home and running a 2 December version of GRASS 5.7 cvs on my Mac OSX
laptop. I have a newer version on my lab Mac but can't get at it at the
moment. However, one of my grad students has been doing a lot with nviz in
the last couple days on a 13 December version of GRASS 5.7 cvs and (without
systematic testing) it seems to behave the same.

When I run nviz from the GUI it runs fine. This is using the 'execute'
procedure which is essentially exec [cmd] &, which brings up the
autogenerated GUI dialog. Whether I add a raster (or other) map or run it
with the -q flag from this environment, it runs in the background without
any problems

When I run nviz from the GRASS command prompt it runs exactly the same as
above *IF* I simply type nviz [return], bringing up the autogenerated GUI.

However, if I type from the GRASS command prompt "nviz -q & [return]", it
runs differently. NVIZ works fine UNTIL I return to the command prompt and
hit [return]. I've copied the terminal output below. Note that it goes to
the Wish "%" prompt (this doesn't happen if I start nviz either of the other
2 ways).

GRASS 5.7.cvs:~ > nviz -q &
[1] 1503
GRASS 5.7.cvs:~ > *** malloc[1503]: Deallocation of a pointer not malloced:
0x29e4248; This could be a double free(), or free() called with the middle
of an allocated block; Try setting environment variable MallocHelp to see
tools to help debug
*** malloc[1503]: Deallocation of a pointer not malloced: 0x2b7e108; This
could be a double free(), or free() called with the middle of an allocated
block; Try setting environment variable MallocHelp to see tools to help
debug
%

[1]+ Stopped nviz -q
GRASS 5.7.cvs:~ >

At this point nviz freezes. I can't get it to do anything and I can't quit
it. The rest of GRASS works fine, both from the command prompt and from the
tcltk GIS Manager. However, the only way I can quit nviz is to completely
exit X-11 on my Mac.

I hope this helps.

Michael

On 12/18/04 11:36 AM, "Huidae Cho" <grass4u@gmail.com> wrote:

Hi, output is the following:

GRASS 5.7.cvs:~/tmp > cat a
#!/bin/sh
exec nviz "$0" "$@"
GRASS 5.7.cvs:~/tmp > ./a elev=dem&
[1] 1112
GRASS 5.7.cvs:~/tmp > Loading Data
Loading Data
translating colors
recalculating normals...
% w 100

[1]+ Stopped ./a elev=dem
GRASS 5.7.cvs:~/tmp >

It stops just after displaying map and empty control windows and
if I "fg", it starts working again.

I think behavior is not consistent from system to system.

Huidae Cho

On Sat, Dec 18, 2004 at 04:29:33PM +0000, Bob Covill wrote:

Hi,

This is an interesting one. If I execute something like "nviz -q &", nviz

starts up normally with the wish (%) prompt. If I hit enter at the prompt I

am returned to the normal command line prompt and can run other commands

(while nviz is running). When I quit nviz I get the respone on the command

line ...

[1]+ Done nviz -q

which is what I would expect from a command that has been running in the

background.

Out of curiousity try creating a simple startup script with the following:

#!/bin/sh

exec nviz "$0" "$@"

Make it executable and try running it in the background. For example if you

name the script nv_start.sh, try "nv_start.sh elev=dem &" and see if that

works.

--

Bob

On 12/18/2004, "Huidae Cho" <grass4u@gmail.com> wrote:

Interesting!

Is wish running in background? As I know, a shell-like program cannot be

running in that way because if it's bg'ed or run with "&", /bin/sh or

the login shell takes control of stdin so that users can stay in the login

shell.

If it's executed by a script, then it's ok because it's a usual shell

script.

Do you mean running "nviz" and executing other programs in the "%" nviz

prompt instead of running "nviz &"?

If wish is running in background (wish &), how can you execute wish

functions?

Thank you.

Huidae Cho

On Sat, Dec 18, 2004 at 01:22:50PM +0000, Bob Covill wrote:

Hi,

It appears that not even wish will run in the background on your system

...

very strange.

The current nviz IS the old NVWISH executable which was called was called

by

the old nviz shell script. The reason I got rid of the shell script was

because when nviz encountered an error the same un-informitive message

was

generated because it was passed through the script. Also, there are a

number

of error catches in the actual nviz tcl scripts which were completely

ignored

with the old shell startup.

Before reverting to the old startup it would be nice to know why wish

(and

nviz) will not run in the background on some systems. On both of my

RedHat

systems it runs fine both in the background and the foreground.

--

Bob

On 12/18/2004, "Huidae Cho" <grass4u@gmail.com> wrote:

Hi,

Now nviz is not a *wish script but a shell itself. That's why it prints

a prompt and we cannot execute it background and inside "d.m &". To fix

this problem, I think we should go back to NVWISH because running nviz

foreground is pain.

You can test this:

wish &

prints % prompt and just stop!

Huidae Cho

On Fri, Dec 17, 2004 at 09:02:39PM -0400, Bob Covill wrote:

Hello,

I tried running the latest version of nviz in the background with

various options and it seems to work fine. The "%" prompt that you see

is perfectly normal. The nviz program is simply a customized version

of

the Tcl/Tk "wish" executable. Try executing "wish" on the command line

and you should see the same prompt.

As for it crashing when it is run in the background, I have no idea.

You

might try changing GRASS_MESSAGE_FORMAT environment variable to see if

that has any effect.

It might help to know what platform and Tcl/Tk version it is failing

on.

For me it works on RedHat 7.3 with Tk8.3, and RedHat 9 with Tk8.4.

--

Bob

Helena wrote:

Huidae Cho wrote:

Hi,

I noticed today that nviz doesn't work if I run it background as

before.

Similarly, it just stops after displaying a map when it's executed

from

"d.m &" which is recommended in the welcome message.

nviz elevation=dem & # doesn't work

d.m & # nviz doesn't work

nviz elevation=dem # works!

d.m # nviz works!

And I see nviz prints % prompt. Does anyone have a clue?

It must be the latest change that was done - I just tried it and it

does not work even if I do nviz elevation=dem, it displays the DEM

but fails to open the Main pannel and prints a % prompt.

It worked OK just a few days (weeks?) ago.

It may be related to the change in the startup script - Bob, are you

around? How does it work for you?

Helena

Thanks.

Huidae Cho

_______________________________________________

grass5 mailing list

grass5@grass.itc.it

http://grass.itc.it/mailman/listinfo/grass5

_______________________________________________

grass5 mailing list

grass5@grass.itc.it

http://grass.itc.it/mailman/listinfo/grass5

____________________
C. Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
PO Box 872402
Arizona State University
Tempe, AZ 85287-2402
USA

Phone: 480-965-6262
Fax: 480-965-7671
www: <www.public.asu.edu/~cmbarton>

Hi,

I was finally able to duplicate the background error on my RedHat 7.3 system. For some reason it works fine on my RedHat 9 system.

I have searched the Tcl/Tk archives for documentation of similar problems, but found nothing.

In the meantime I have got the following script to work.

#!/bin/sh
exec nviz -f $GISBASE/etc/nviz2.2/scripts/nviz2.2_script "$@"

This seems to work if started in the foreground or background, but I have not tested it properly. In order to use the above script you have to first edit nviz_init.c in visualization/nviz/src and comment out the following line ...

     if (!script_mode)
             Tcl_Eval(interp, nviz_script); /* source nviz_script to start main window */

After commenting, rebuild nviz and run the above script. Hopefully this will work for you.

Now that I have an idea of where the problem is originating, hopefully I can figure out a more permanent solution. Suggestions welcome.

--
Bob

Huidae Cho wrote:

Hi, output is the following:

GRASS 5.7.cvs:~/tmp > cat a
#!/bin/sh
exec nviz "$0" "$@"
GRASS 5.7.cvs:~/tmp > ./a elev=dem&
[1] 1112
GRASS 5.7.cvs:~/tmp > Loading Data
Loading Data
translating colors
recalculating normals...
% w 100

[1]+ Stopped ./a elev=dem
GRASS 5.7.cvs:~/tmp >

It stops just after displaying map and empty control windows and
if I "fg", it starts working again.

I think behavior is not consistent from system to system.

Huidae Cho

On Sat, Dec 18, 2004 at 04:29:33PM +0000, Bob Covill wrote:

Hi,

This is an interesting one. If I execute something like "nviz -q &", nviz

starts up normally with the wish (%) prompt. If I hit enter at the prompt I

am returned to the normal command line prompt and can run other commands

(while nviz is running). When I quit nviz I get the respone on the command

line ...

[1]+ Done nviz -q

which is what I would expect from a command that has been running in the

background.

Out of curiousity try creating a simple startup script with the following:

#!/bin/sh

exec nviz "$0" "$@"

Make it executable and try running it in the background. For example if you

name the script nv_start.sh, try "nv_start.sh elev=dem &" and see if that

works.

--

Bob

On 12/18/2004, "Huidae Cho" <grass4u@gmail.com> wrote:

Interesting!

Is wish running in background? As I know, a shell-like program cannot be

running in that way because if it's bg'ed or run with "&", /bin/sh or

the login shell takes control of stdin so that users can stay in the login

shell.

If it's executed by a script, then it's ok because it's a usual shell

script.

Do you mean running "nviz" and executing other programs in the "%" nviz

prompt instead of running "nviz &"?

If wish is running in background (wish &), how can you execute wish

functions?

Thank you.

Huidae Cho

On Sat, Dec 18, 2004 at 01:22:50PM +0000, Bob Covill wrote:

Hi,

It appears that not even wish will run in the background on your system

...

very strange.

The current nviz IS the old NVWISH executable which was called was called

by

the old nviz shell script. The reason I got rid of the shell script was

because when nviz encountered an error the same un-informitive message

was

generated because it was passed through the script. Also, there are a

number

of error catches in the actual nviz tcl scripts which were completely

ignored

with the old shell startup.

Before reverting to the old startup it would be nice to know why wish

(and

nviz) will not run in the background on some systems. On both of my

RedHat

systems it runs fine both in the background and the foreground.

--

Bob

On 12/18/2004, "Huidae Cho" <grass4u@gmail.com> wrote:

Hi,

Now nviz is not a *wish script but a shell itself. That's why it prints

a prompt and we cannot execute it background and inside "d.m &". To fix

this problem, I think we should go back to NVWISH because running nviz

foreground is pain.

You can test this:

wish &

prints % prompt and just stop!

Huidae Cho

On Fri, Dec 17, 2004 at 09:02:39PM -0400, Bob Covill wrote:

Hello,

I tried running the latest version of nviz in the background with

various options and it seems to work fine. The "%" prompt that you see

is perfectly normal. The nviz program is simply a customized version

of

the Tcl/Tk "wish" executable. Try executing "wish" on the command line

and you should see the same prompt.

As for it crashing when it is run in the background, I have no idea.

You

might try changing GRASS_MESSAGE_FORMAT environment variable to see if

that has any effect.

It might help to know what platform and Tcl/Tk version it is failing

on.

For me it works on RedHat 7.3 with Tk8.3, and RedHat 9 with Tk8.4.

--

Bob

Helena wrote:

Huidae Cho wrote:

Hi,

I noticed today that nviz doesn't work if I run it background as

before.

Similarly, it just stops after displaying a map when it's executed

from

"d.m &" which is recommended in the welcome message.

nviz elevation=dem & # doesn't work

d.m & # nviz doesn't work

nviz elevation=dem # works!

d.m # nviz works!

And I see nviz prints % prompt. Does anyone have a clue?

It must be the latest change that was done - I just tried it and it

does not work even if I do nviz elevation=dem, it displays the DEM

but fails to open the Main pannel and prints a % prompt.

It worked OK just a few days (weeks?) ago.

It may be related to the change in the startup script - Bob, are you

around? How does it work for you?

Helena

Thanks.

Huidae Cho

_______________________________________________

grass5 mailing list

grass5@grass.itc.it

http://grass.itc.it/mailman/listinfo/grass5

_______________________________________________

grass5 mailing list

grass5@grass.itc.it

http://grass.itc.it/mailman/listinfo/grass5

--
Bob Covill

Tekmap Consulting
P.O. Box 2016
Fall River, N.S.
B2T 1K6
Canada

E-Mail: bcovill@tekmap.ns.ca
Phone: 902-860-1496
Fax: 902-860-1498

Hi,

The script is mean't as a temporary fix so that you can run nviz with
options in the background (&). Try "./i -q &" and nviz should start up
in quick mode running in the background.

Nviz uses both G_parser and wish style arguments. In other words nviz is
   a customized version of wish that accepts GRASS style commands. The
trick is to make sure that the GRASS commands are not stripped out by
the TK wish portion. The "-f" flag tells it to execute the script
(nviz2.2_script in our case) in the same way that wish would execute a
script. Remember that the current nviz executable is simply the old
NVWISH renamed.

The problem seems to be related to the fact that nviz2.2_script is
currently executed internally with Tcl_Eval. If nviz is executed in the
background the whole thing hangs up. The trick is to figure out how to
call this correctly?

--
Bob

Huidae Cho wrote:
> Hi,
>
> Your fix doesn't work:
> ----------------------
> GRASS 5.7.cvs:~/tmp > cat i
> #!/bin/sh
> exec nviz -f $GISBASE/etc/nviz2.2/scripts/nviz2.2_script "$@"
> GRASS 5.7.cvs:~/tmp > ./i
> Illegal filename. character </> not allowed.Error: Raster /home/geni/usr/grass/grass51/dist.i686-pc-cygwin/etc/nviz2.2/scripts/nviz2.2_script does not exist in current Mapset
> Load Failed
> GRASS 5.7.cvs:~/tmp >
> ----------------------
>
> nviz2.2_script is not a map but a script. The error message comes from the
> grass parser library not from tcl/tk. I think nviz is a grass module itself,
> so it doesn't accept parameters except grass ones.
>
> If -f option is given:
> nviz -f nviz_script grass parameters
>
> Otherwise:
> nviz -- grass parameters
>
> This is what I understand, but where does nviz do something for "-f"
> option? I cannot find it.
>
> When I run "nviz -f elev=dem500" which should be wrong, nviz displays
> dem500 and tries to find "elev=dem500" script without success:
> ----------------------
> Loading Data
> translating colors from fp
> recalculating normals...
> Error in startup script: couldn't read file "elev=dem500": no such file
> or directory
> ----------------------
>
> I think the tcl/tk parser conflicts with the grass parser and maybe
> tcl/tk sould have a priority here.
>
> Thank you.
> Huidae Cho
>
> On Mon, Dec 20, 2004 at 09:18:11AM -0400, Bob Covill wrote:
>
>>Hi,
>>
>>I was finally able to duplicate the background error on my RedHat 7.3
>>system. For some reason it works fine on my RedHat 9 system.
>>
>>I have searched the Tcl/Tk archives for documentation of similar
>>problems, but found nothing.
>>
>>In the meantime I have got the following script to work.
>>
>>#!/bin/sh
>>exec nviz -f $GISBASE/etc/nviz2.2/scripts/nviz2.2_script "$@"
>>
>>This seems to work if started in the foreground or background, but I
>>have not tested it properly. In order to use the above script you have
>>to first edit nviz_init.c in visualization/nviz/src and comment out the
>>following line ...
>>
>> if (!script_mode)
>> Tcl_Eval(interp, nviz_script); /* source nviz_script to
>>start main window */
>>
>>After commenting, rebuild nviz and run the above script. Hopefully this
>>will work for you.
>>
>>Now that I have an idea of where the problem is originating, hopefully I
>>can figure out a more permanent solution. Suggestions welcome.
>>
>>--
>>Bob
>>
>>Huidae Cho wrote:
>>
>>>Hi, output is the following:
>>>
>>>GRASS 5.7.cvs:~/tmp > cat a
>>>#!/bin/sh
>>>exec nviz "$0" "$@"
>>>GRASS 5.7.cvs:~/tmp > ./a elev=dem&
>>>[1] 1112
>>>GRASS 5.7.cvs:~/tmp > Loading Data
>>>Loading Data
>>>translating colors
>>>recalculating normals...
>>>% w 100
>>>
>>>[1]+ Stopped ./a elev=dem
>>>GRASS 5.7.cvs:~/tmp >
>>>
>>>It stops just after displaying map and empty control windows and
>>>if I "fg", it starts working again.
>>>
>>>I think behavior is not consistent from system to system.
>>>
>>>Huidae Cho
>>>
>>>On Sat, Dec 18, 2004 at 04:29:33PM +0000, Bob Covill wrote:
>>>
>>>>Hi,
>>>>
>>>>This is an interesting one. If I execute something like "nviz -q &", nviz
>>>>
>>>>starts up normally with the wish (%) prompt. If I hit enter at the prompt
>>>>I
>>>>
>>>>am returned to the normal command line prompt and can run other commands
>>>>
>>>>(while nviz is running). When I quit nviz I get the respone on the command
>>>>
>>>>line ...
>>>>
>>>>[1]+ Done nviz -q
>>>>
>>>>which is what I would expect from a command that has been running in the
>>>>
>>>>background.
>>>>
>>>>Out of curiousity try creating a simple startup script with the following:
>>>>
>>>>#!/bin/sh
>>>>
>>>>exec nviz "$0" "$@"
>>>>
>>>>Make it executable and try running it in the background. For example if
>>>>you
>>>>
>>>>name the script nv_start.sh, try "nv_start.sh elev=dem &" and see if that
>>>>
>>>>works.
>>>>
>>>>--
>>>>
>>>>Bob
>>>>
>>>>On 12/18/2004, "Huidae Cho" <grass4u@gmail.com> wrote:
>>>>
>>>>>Interesting!
>>>>
>>>>>Is wish running in background? As I know, a shell-like program cannot be
>>>>
>>>>>running in that way because if it's bg'ed or run with "&", /bin/sh or
>>>>
>>>>>the login shell takes control of stdin so that users can stay in the
>>>>>login
>>>>
>>>>>shell.
>>>>
>>>>>If it's executed by a script, then it's ok because it's a usual shell
>>>>
>>>>>script.
>>>>
>>>>>Do you mean running "nviz" and executing other programs in the "%" nviz
>>>>
>>>>>prompt instead of running "nviz &"?
>>>>
>>>>>If wish is running in background (wish &), how can you execute wish
>>>>
>>>>functions?
>>>>
>>>>>Thank you.
>>>>
>>>>>Huidae Cho
>>>>
>>>>>On Sat, Dec 18, 2004 at 01:22:50PM +0000, Bob Covill wrote:
>>>>
>>>>>>Hi,
>>>>>
>>>>>>It appears that not even wish will run in the background on your system
>>>>>
>>>>...
>>>>
>>>>>>very strange.
>>>>>
>>>>>>The current nviz IS the old NVWISH executable which was called was
>>>>>>called
>>>>>
>>>>by
>>>>
>>>>>>the old nviz shell script. The reason I got rid of the shell script was
>>>>>
>>>>>>because when nviz encountered an error the same un-informitive message
>>>>>
>>>>was
>>>>
>>>>>>generated because it was passed through the script. Also, there are a
>>>>>
>>>>number
>>>>
>>>>>>of error catches in the actual nviz tcl scripts which were completely
>>>>>
>>>>ignored
>>>>
>>>>>>with the old shell startup.
>>>>>
>>>>>>Before reverting to the old startup it would be nice to know why wish
>>>>>
>>>>(and
>>>>
>>>>>>nviz) will not run in the background on some systems. On both of my
>>>>>
>>>>RedHat
>>>>
>>>>>>systems it runs fine both in the background and the foreground.
>>>>>
>>>>>>--
>>>>>
>>>>>>Bob
>>>>>
>>>>>>On 12/18/2004, "Huidae Cho" <grass4u@gmail.com> wrote:
>>>>>
>>>>>>>Hi,
>>>>>>
>>>>>>>Now nviz is not a *wish script but a shell itself. That's why it prints
>>>>>>
>>>>>>>a prompt and we cannot execute it background and inside "d.m &". To fix
>>>>>>
>>>>>>>this problem, I think we should go back to NVWISH because running nviz
>>>>>>
>>>>>>>foreground is pain.
>>>>>>
>>>>>>>You can test this:
>>>>>>
>>>>>>> wish &
>>>>>>
>>>>>>>prints % prompt and just stop!
>>>>>>
>>>>>>>Huidae Cho
>>>>>>
>>>>>>>On Fri, Dec 17, 2004 at 09:02:39PM -0400, Bob Covill wrote:
>>>>>>
>>>>>>>>Hello,
>>>>>>>
>>>>>>>>I tried running the latest version of nviz in the background with
>>>>>>>
>>>>>>>>various options and it seems to work fine. The "%" prompt that you see
>>>>>>>
>>>>>>>>is perfectly normal. The nviz program is simply a customized version
>>>>>>>
>>>>of
>>>>
>>>>>>>>the Tcl/Tk "wish" executable. Try executing "wish" on the command line
>>>>>>>
>>>>>>>>and you should see the same prompt.
>>>>>>>
>>>>>>>>As for it crashing when it is run in the background, I have no idea.
>>>>>>>
>>>>You
>>>>
>>>>>>>>might try changing GRASS_MESSAGE_FORMAT environment variable to see if
>>>>>>>
>>>>>>>>that has any effect.
>>>>>>>
>>>>>>>>It might help to know what platform and Tcl/Tk version it is failing
>>>>>>>
>>>>on.
>>>>
>>>>>>>>For me it works on RedHat 7.3 with Tk8.3, and RedHat 9 with Tk8.4.
>>>>>>>
>>>>>>>>--
>>>>>>>
>>>>>>>>Bob
>>>>>>>
>>>>>>>>Helena wrote:
>>>>>>>
>>>>>>>>>Huidae Cho wrote:
>>>>>>>>
>>>>>>>>>>Hi,
>>>>>>>>>
>>>>>>>>>>I noticed today that nviz doesn't work if I run it background as
>>>>>>>>>
>>>>>>before.
>>>>>
>>>>>>>>>>Similarly, it just stops after displaying a map when it's executed
>>>>>>>>>
>>>>from
>>>>
>>>>>>>>>>"d.m &" which is recommended in the welcome message.
>>>>>>>>>
>>>>>>>>>>nviz elevation=dem & # doesn't work
>>>>>>>>>
>>>>>>>>>>d.m & # nviz doesn't work
>>>>>>>>>
>>>>>>>>>>nviz elevation=dem # works!
>>>>>>>>>
>>>>>>>>>>d.m # nviz works!
>>>>>>>>>
>>>>>>>>>>And I see nviz prints % prompt. Does anyone have a clue?
>>>>>>>>>
>>>>>>>>>It must be the latest change that was done - I just tried it and it
>>>>>>>>
>>>>>>>>>does not work even if I do nviz elevation=dem, it displays the DEM
>>>>>>>>
>>>>>>>>>but fails to open the Main pannel and prints a % prompt.
>>>>>>>>
>>>>>>>>>It worked OK just a few days (weeks?) ago.
>>>>>>>>
>>>>>>>>>It may be related to the change in the startup script - Bob, are you
>>>>>>>>
>>>>>>>>>around? How does it work for you?
>>>>>>>>
>>>>>>>>>Helena
>>>>>>>>
>>>>>>>>>>Thanks.
>>>>>>>>>
>>>>>>>>>>Huidae Cho
>>>>>>>>>
>>>>>>>>>>_______________________________________________
>>>>>>>>>
>>>>>>>>>>grass5 mailing list
>>>>>>>>>
>>>>>>>>>>grass5@grass.itc.it
>>>>>>>>>
>>>>>>>>>>http://grass.itc.it/mailman/listinfo/grass5
>>>>>>>>>
>>>>>_______________________________________________
>>>>
>>>>>grass5 mailing list
>>>>
>>>>>grass5@grass.itc.it
>>>>
>>>>>http://grass.itc.it/mailman/listinfo/grass5
>>>>
>>>
>>
>>--
>>Bob Covill
>>
>>Tekmap Consulting
>>P.O. Box 2016
>>Fall River, N.S.
>>B2T 1K6
>>Canada
>>
>>E-Mail: bcovill@tekmap.ns.ca
>>Phone: 902-860-1496
>>Fax: 902-860-1498
>

--
Bob Covill

Tekmap Consulting
P.O. Box 2016
Fall River, N.S.
B2T 1K6
Canada

E-Mail: bcovill@tekmap.ns.ca
Phone: 902-860-1496
Fax: 902-860-1498

[I'm currently recovering from a hard drive failure, and have only
just started catching up on the email backlog.]

Bob Covill wrote:

The script is mean't as a temporary fix so that you can run nviz with
options in the background (&). Try "./i -q &" and nviz should start up
in quick mode running in the background.

Nviz uses both G_parser and wish style arguments. In other words nviz is
   a customized version of wish that accepts GRASS style commands. The
trick is to make sure that the GRASS commands are not stripped out by
the TK wish portion. The "-f" flag tells it to execute the script
(nviz2.2_script in our case) in the same way that wish would execute a
script. Remember that the current nviz executable is simply the old
NVWISH renamed.

The problem seems to be related to the fact that nviz2.2_script is
currently executed internally with Tcl_Eval. If nviz is executed in the
background the whole thing hangs up. The trick is to figure out how to
call this correctly?

When run without the -f switch, "wish" behaves like a shell, i.e. it
reads from stdin. If wish is run via a shell running on a terminal,
stdin will normally refer to the process' controlling terminal.

If a process which isn't a member of the foreground process group
(i.e. one which is running in the background) attempts to read from
the controlling terminal, it will receive SIGTTIN; the default
behaviour of that signal is to suspend the process (similar to SIGSTOP
and SIGTSTP).

NVIZ shouldn't behave like a shell so, if it is implemented as a
typical "enhanced wish", it must always be run with the "-f" switch.

IMHO, eliminating the nviz script and renaming the NVWISH2.2
executable to "nviz" was a mistake. I presume that this was done in
response to the G_gui() issues, but I think that it's the wrong
approach.

It would probably have been better to force G_gui() to call "nviz"
rather than using the name of the current executable, either by
manipulating argv or by adding a function to parser.c to allow a
module to specify its name.

--
Glynn Clements <glynn@gclements.plus.com>

[I'm currently recovering from a hard drive failure, and have only
just started catching up on the email backlog.]

Bob Covill wrote:

The script is mean't as a temporary fix so that you can run nviz with
options in the background (&). Try "./i -q &" and nviz should start up
in quick mode running in the background.

Nviz uses both G_parser and wish style arguments. In other words nviz is
   a customized version of wish that accepts GRASS style commands. The
trick is to make sure that the GRASS commands are not stripped out by
the TK wish portion. The "-f" flag tells it to execute the script
(nviz2.2_script in our case) in the same way that wish would execute a
script. Remember that the current nviz executable is simply the old
NVWISH renamed.

The problem seems to be related to the fact that nviz2.2_script is
currently executed internally with Tcl_Eval. If nviz is executed in the
background the whole thing hangs up. The trick is to figure out how to
call this correctly?

When run without the -f switch, "wish" behaves like a shell, i.e. it
reads from stdin. If wish is run via a shell running on a terminal,
stdin will normally refer to the process' controlling terminal.

If a process which isn't a member of the foreground process group
(i.e. one which is running in the background) attempts to read from
the controlling terminal, it will receive SIGTTIN; the default
behaviour of that signal is to suspend the process (similar to SIGSTOP
and SIGTSTP).

NVIZ shouldn't behave like a shell so, if it is implemented as a
typical "enhanced wish", it must always be run with the "-f" switch.

IMHO, eliminating the nviz script and renaming the NVWISH2.2
executable to "nviz" was a mistake. I presume that this was done in
response to the G_gui() issues, but I think that it's the wrong
approach.

It would probably have been better to force G_gui() to call "nviz"
rather than using the name of the current executable, either by
manipulating argv or by adding a function to parser.c to allow a
module to specify its name.

--
Glynn Clements <glynn@gclements.plus.com>

Glynn,

The original reason I had changed nviz to run directly as nvwish was the error handling. All errors seemed to generate the same unhelpful output when passed through the original script. Somthing along the line of ...

.............
child killed: segmentation violation
     while executing
"exec /usr/local/grass5/etc/nviz2.2/NVWISH2.2 -f
/usr/local/grass5/etc/nviz2.2/scripts/nviz2.2_script -q -name NVIZ
>&@stdout"
     ("eval" body line 1)
     invoked from within
"eval exec $env(GISBASE)/etc/nviz2.2/NVWISH2.2 -f
$env(GISBASE)/etc/nviz2.2/scripts/nviz2.2_script $argv -name NVIZ >&@stdout"
     invoked from within
"if {$argv == ""} {
#no arguments
eval exec $env(GISBASE)/etc/nviz2.2/NVWISH2.2 -f
$env(GISBASE)/etc/nviz2.2/scripts/nviz2.2_script -name NVIZ >&@stdou..."
.................

This wasn't very helpful. It generates the same message whether a minor error or a more complex error is encountered. As an example try starting nviz with state=fakename. The old version would fatally crash with an error similar to above. If passed directly to nvwish (new version) a non-fatal error window tells you the file does not exist.

Interestingly, when I started looking into this I notice that v.digit is written as a modified wish (I think?).

What would be the best front-end to nviz? It needs to satisfy G_gui(), allow errors to handled more cleanly, and allow by-passing G_parser when in script mode.

--

Bob

Glynn Clements wrote:

[I'm currently recovering from a hard drive failure, and have only
just started catching up on the email backlog.]

Bob Covill wrote:

The script is mean't as a temporary fix so that you can run nviz with
options in the background (&). Try "./i -q &" and nviz should start up
in quick mode running in the background.

Nviz uses both G_parser and wish style arguments. In other words nviz is
  a customized version of wish that accepts GRASS style commands. The
trick is to make sure that the GRASS commands are not stripped out by
the TK wish portion. The "-f" flag tells it to execute the script
(nviz2.2_script in our case) in the same way that wish would execute a
script. Remember that the current nviz executable is simply the old
NVWISH renamed.

The problem seems to be related to the fact that nviz2.2_script is
currently executed internally with Tcl_Eval. If nviz is executed in the
background the whole thing hangs up. The trick is to figure out how to
call this correctly?

When run without the -f switch, "wish" behaves like a shell, i.e. it
reads from stdin. If wish is run via a shell running on a terminal,
stdin will normally refer to the process' controlling terminal.

If a process which isn't a member of the foreground process group
(i.e. one which is running in the background) attempts to read from
the controlling terminal, it will receive SIGTTIN; the default
behaviour of that signal is to suspend the process (similar to SIGSTOP
and SIGTSTP).

NVIZ shouldn't behave like a shell so, if it is implemented as a
typical "enhanced wish", it must always be run with the "-f" switch.

IMHO, eliminating the nviz script and renaming the NVWISH2.2
executable to "nviz" was a mistake. I presume that this was done in
response to the G_gui() issues, but I think that it's the wrong
approach.

It would probably have been better to force G_gui() to call "nviz"
rather than using the name of the current executable, either by
manipulating argv or by adding a function to parser.c to allow a
module to specify its name.

Bob Covill wrote:

The original reason I had changed nviz to run directly as nvwish was the
error handling. All errors seemed to generate the same unhelpful output
when passed through the original script. Somthing along the line of ...

.............
child killed: segmentation violation
     while executing
"exec /usr/local/grass5/etc/nviz2.2/NVWISH2.2 -f
/usr/local/grass5/etc/nviz2.2/scripts/nviz2.2_script -q -name NVIZ
>&@stdout"
     ("eval" body line 1)

Right. The easiest solution to that issue is to rewrite the "nviz"
script as a Bourne-shell script instead of a Tcl script.

Bourne shell doesn't print anything if an external command fails.

Interestingly, when I started looking into this I notice that v.digit is
written as a modified wish (I think?).

v.digit uses the "form" library (as does d.what.vect). Most of the
functions in that library just send data to an external program, which
is a modified wish (sort of; it tries to do too much in C, which is
probably why it isn't particularly reliable).

What would be the best front-end to nviz? It needs to satisfy G_gui(),
allow errors to handled more cleanly, and allow by-passing G_parser when
in script mode.

The error messages can be fixed by using /bin/sh instead of Tcl.

The G_gui() issues can be fixed by either:

a) having NVWISH2.2 force the program name to "nviz" (this may require
the addition of e.g. G_set_program_name() to parser.c, but that's
trivial), or

b) making the "nviz" script use g.parser (so, in the G_gui() case, the
re-execution is performed before NVWISH2.2 gets involved).

--
Glynn Clements <glynn@gclements.plus.com>

Hi Bob,

Do you have any progress on this nviz background issue?

Thank you.
Huidae Cho

On Thu, Jan 06, 2005 at 10:29:33PM +0000, Glynn Clements wrote:

Bob Covill wrote:

> The original reason I had changed nviz to run directly as nvwish was the
> error handling. All errors seemed to generate the same unhelpful output
> when passed through the original script. Somthing along the line of ...
>
> .............
> child killed: segmentation violation
> while executing
> "exec /usr/local/grass5/etc/nviz2.2/NVWISH2.2 -f
> /usr/local/grass5/etc/nviz2.2/scripts/nviz2.2_script -q -name NVIZ
> >&@stdout"
> ("eval" body line 1)

Right. The easiest solution to that issue is to rewrite the "nviz"
script as a Bourne-shell script instead of a Tcl script.

Bourne shell doesn't print anything if an external command fails.

> Interestingly, when I started looking into this I notice that v.digit is
> written as a modified wish (I think?).

v.digit uses the "form" library (as does d.what.vect). Most of the
functions in that library just send data to an external program, which
is a modified wish (sort of; it tries to do too much in C, which is
probably why it isn't particularly reliable).

> What would be the best front-end to nviz? It needs to satisfy G_gui(),
> allow errors to handled more cleanly, and allow by-passing G_parser when
> in script mode.

The error messages can be fixed by using /bin/sh instead of Tcl.

The G_gui() issues can be fixed by either:

a) having NVWISH2.2 force the program name to "nviz" (this may require
the addition of e.g. G_set_program_name() to parser.c, but that's
trivial), or

b) making the "nviz" script use g.parser (so, in the G_gui() case, the
re-execution is performed before NVWISH2.2 gets involved).

--
Glynn Clements <glynn@gclements.plus.com>