[GRASS-dev] Re: [GRASS GIS] #7: Location wizard: should predefine DB connection for new location

Hamish hamish_b at yahoo.com
Thu Mar 13 14:23:34 EDT 2008


> Eric:
> >> Thanks for the pointer. I'll hardcode my database paths for now.
> 
> Hamish:
> > see the db.connect help page example for DBF (I usually just cut
> > and paste that to the command line when needed). It accepts
> > variable LOCATION, MAPSET, you don't need to hardcode it. (Be sure
> > to keep the path with $VARIABLES in single quotes!)

Eric:
> Should each of $GISDABSE, $LOCATION_NAME, and $MAPSET have populated
> values on location startup? These variables always remain blank for
> each location that I try:
> 
> ~ >echo $GISDBASE
> ~ >echo $LOCATION_NAME
> ~ >echo $MAPSET
> ~ >
> 
> are these variables only available from the shell if I export
> `g.gisenv` or eval `g.gisenv` first?

If you want to use them as variables from the shell you should use
  eval `g.gisenv`
first. Back in the GRASS 5 days they used to be set all the time but
this caused problems if you had the GUI running and then from the
terminal window you changed e.g. the mapset with g.mapset. The already
launched GUI would not and could not know about the change. So g.gisenv
was created to hold those variables.


But this has nothing (or at least little) to do with the task at hand.
db.connect will parse those variables itself, which is why you have to
enclose them in single quotes when given on the command line- to
prevent the shell from attempting to expand them (into nothing).

so just cut and paste:
 db.connect driver=dbf database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'

and it works.


Hamish



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 




More information about the grass-dev mailing list