[GRASS-user] v.db.connect error (Grass 6.4.0RC4 on OSX 10.5.8)

Hi,

There is a slip in the command-line parsing of v.db.connect.
The GUI works ok, but the same command, pasted to the command line, produces this:

> v.db.connect -o map=CD_act driver=dbf database=$GISDBE/$LOCATION_NAME/$MAPSET/dbf table=cd_act_2 key=cat layer=1
>
> ERROR: Table <cd_act_2> does not exist in database <///dbf>

Note the extra slash characters added by v.db.connect here...

Richard Chirgwin

Richard Chirgwin wrote:

There is a slip in the command-line parsing of v.db.connect.

The GUI works ok, but the same command, pasted to the command line,
produces this:

> v.db.connect -o map=CD_act driver=dbf
database=$GISDBE/$LOCATION_NAME/$MAPSET/dbf table=cd_act_2 key=cat layer=1
>
> ERROR: Table <cd_act_2> does not exist in database <///dbf>

Note the extra slash characters added by v.db.connect here...

This isn't a problem with db.connect, but with the way that you ran it
from the shell.

You need to quote the database= option (with single quotes), otherwise
the shell will interpret $GISDBASE, $LOCATION_NAME, and $MAPSET as
variable substitutions. As these variables aren't defined, they are
replaced by the empty string, giving the result you see.

IOW:

v.db.connect -o map=CD_act driver=dbf 'database=$GISDBASE/$LOCATION_NAME/$MAPSET/dbf' table=cd_act_2 key=cat layer=1

If you run v.db.connect from the GUI, the shell doesn't get involved,
so this isn't an issue.

bash (which I assume that you're using) has quite thorough
documentation (around 80 pages) available via "man bash" or at:

  http://www.gnu.org/software/bash/manual/

While much of that information is only necessary for scripting, it is
important to learn which constructs the shell interprets, and how to
prevent it from doing so.

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

Glynn,

Thanks ...

(Chastened)

Cheers
RC

Glynn Clements wrote:

Richard Chirgwin wrote:

There is a slip in the command-line parsing of v.db.connect.
The GUI works ok, but the same command, pasted to the command line, produces this:

> v.db.connect -o map=CD_act driver=dbf database=$GISDBE/$LOCATION_NAME/$MAPSET/dbf table=cd_act_2 key=cat layer=1
>
> ERROR: Table <cd_act_2> does not exist in database <///dbf>

Note the extra slash characters added by v.db.connect here...
    
This isn't a problem with db.connect, but with the way that you ran it
from the shell.

You need to quote the database= option (with single quotes), otherwise
the shell will interpret $GISDBASE, $LOCATION_NAME, and $MAPSET as
variable substitutions. As these variables aren't defined, they are
replaced by the empty string, giving the result you see.

IOW:

v.db.connect -o map=CD_act driver=dbf 'database=$GISDBASE/$LOCATION_NAME/$MAPSET/dbf' table=cd_act_2 key=cat layer=1

If you run v.db.connect from the GUI, the shell doesn't get involved,
so this isn't an issue.

bash (which I assume that you're using) has quite thorough
documentation (around 80 pages) available via "man bash" or at:

  http://www.gnu.org/software/bash/manual/

While much of that information is only necessary for scripting, it is
important to learn which constructs the shell interprets, and how to
prevent it from doing so.