[GRASS-dev] Tk implemantation of a query function

Hi everybody,

I'm a beginner in programmation and my goal (as wanted by my boss) is to add a function to make the building of a query easier and more friendly that it is actually (so that people who don't know SQL syntax can build queries !!).
I've made a first script in bash, that works quite well (for postgres, but I'm planning to extend it to other databases used by GRASS). And now, Im'trying to make it more friendly, thru Tk. My problem is the following error :
Error in startup script: can't read "GRASS_WISH": no such variable
    while executing
"exec $GRASS_WISH "$0" "$@""
If I only write "exec $GRASS_WISH" in this line, the error is that it opens a new window and freeze everything...
I think my problems are very small... But can someone helps me ??
I join my code to help !

Thanks

Thierry Gonon
2 Place de l'Eglise
01150 LAGNIEU
Tél : 04 74 34 49 26

(attachments)

db_q_e.tcl (6.69 KB)

On Mon, October 23, 2006 17:27, Thierry Gonon wrote:

Hi everybody,

I'm a beginner in programmation and my goal (as wanted by my boss) is to
add a function to make the building of a query easier and more friendly
that it is actually (so that people who don't know SQL syntax can build
queries !!).
I've made a first script in bash, that works quite well (for postgres, but
I'm planning to extend it to other databases used by GRASS). And now,
Im'trying to make it more friendly, thru Tk. My problem is the following
error :
Error in startup script: can't read "GRASS_WISH": no such variable
    while executing
"exec $GRASS_WISH "$0" "$@""
If I only write "exec $GRASS_WISH" in this line, the error is that it
opens a new window and freeze everything...
I think my problems are very small... But can someone helps me ??
I join my code to help !

I think your second line should end with a backslash:

#!/bin/sh
#Version 0.5 (15 octobre 2006)\
exec $GRASS_WISH "$0" "$@"

The backslash makes sure the line with 'exec' is only visible to the
shell, but not to tcltk (for which it is the continuation of the commented
line 2).

Moritz

Thanks Moritz !

It helps for the beginning, but after that, the problem is that it can't run db.table (I call it this way :
exec {db.tables driver=$DB_DRIVER database=$DB_DATABASE > /tmp/tables}
Anyone can help me (one more time !!) ??

Thanks !

Le lundi, 23 octobre, 2006, à 19h35, Moritz Lennert <mlennert@club.worldonline.be> a écrit :

On Mon, October 23, 2006 17:27, Thierry Gonon wrote:

Hi everybody,

I'm a beginner in programmation and my goal (as wanted by my boss) is to
add a function to make the building of a query easier and more friendly
that it is actually (so that people who don't know SQL syntax can build
queries !!).
I've made a first script in bash, that works quite well (for postgres, but
I'm planning to extend it to other databases used by GRASS). And now,
Im'trying to make it more friendly, thru Tk. My problem is the following
error :
Error in startup script: can't read "GRASS_WISH": no such variable
    while executing
"exec $GRASS_WISH "$0" "$@""
If I only write "exec $GRASS_WISH" in this line, the error is that it
opens a new window and freeze everything...
I think my problems are very small... But can someone helps me ??
I join my code to help !

I think your second line should end with a backslash:

#!/bin/sh
#Version 0.5 (15 octobre 2006)\
exec $GRASS_WISH "$0" "$@"

The backslash makes sure the line with 'exec' is only visible to the
shell, but not to tcltk (for which it is the continuation of the commented
line 2).

Moritz

Thierry Gonon
2 Place de l'Eglise
01150 LAGNIEU
Tél : 04 74 34 49 26

Thierry Gonon wrote:

Thanks Moritz !

It helps for the beginning, but after that, the problem is that it can't run db.table (I call it this way :
exec {db.tables driver=$DB_DRIVER database=$DB_DATABASE > /tmp/tables}
Anyone can help me (one more time !!) ??

I am really not an expert of tcltk, so don't think I can help you much further, but are you sure you need curly braces here ?

If I take them away, it seems to run, with the only problem that the DB_DRIVER variable is empty... Are you sure this variable exists as a gisenv variable ? The same for DB_DATABASE and DB_GROUP ? If they do, I don't think that they are normally set. Try using db.connect instead.

Moritz

Thanks !

Le lundi, 23 octobre, 2006, à 19h35, Moritz Lennert <mlennert@club.worldonline.be> a écrit :

On Mon, October 23, 2006 17:27, Thierry Gonon wrote:

Hi everybody,

I'm a beginner in programmation and my goal (as wanted by my boss) is to
add a function to make the building of a query easier and more friendly
that it is actually (so that people who don't know SQL syntax can build
queries !!).
I've made a first script in bash, that works quite well (for postgres, but
I'm planning to extend it to other databases used by GRASS). And now,
Im'trying to make it more friendly, thru Tk. My problem is the following
error :
Error in startup script: can't read "GRASS_WISH": no such variable
    while executing
"exec $GRASS_WISH "$0" "$@""
If I only write "exec $GRASS_WISH" in this line, the error is that it
opens a new window and freeze everything...
I think my problems are very small... But can someone helps me ??
I join my code to help !

I think your second line should end with a backslash:

#!/bin/sh
#Version 0.5 (15 octobre 2006)\
exec $GRASS_WISH "$0" "$@"

The backslash makes sure the line with 'exec' is only visible to the
shell, but not to tcltk (for which it is the continuation of the commented
line 2).

Moritz

Thierry Gonon
2 Place de l'Eglise
01150 LAGNIEU
Tél : 04 74 34 49 26

Thierry Gonon wrote:

It helps for the beginning, but after that, the problem is that it can't run db.table (I call it this way :
exec {db.tables driver=$DB_DRIVER database=$DB_DATABASE > /tmp/tables}

As Moritz notes, the braces shouldn't be there.

Tcl's "exec" command takes a command as multiple arguments; the first
is the command, the rest are the command's arguments (or
redirections). Each command argument must be passed as a separate
argument to "exec".

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

Thierry Gonon wrote:

#!/bin/sh
#Version 0.5 (15 octobre 2006)
exec $GRASS_WISH "$0" "$@"

why not simply:

#!$GRASS_WISH

or if that doesn't work,

#!/bin/wish

?

Hamish

On Tue, Oct 24, 2006 at 05:30:51PM +1300, Hamish wrote:

Thierry Gonon wrote:
> #!/bin/sh
> #Version 0.5 (15 octobre 2006)
> exec $GRASS_WISH "$0" "$@"

why not simply:

#!$GRASS_WISH

Because shbang requires the absolute path to whatever the shell
executes.

or if that doesn't work,

#!/bin/wish

?

There is no standardized path for wish.

Huidae

Hamish

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