[GRASS-user] problem with script started form directory differend than home

Hi
in the script, which is started from ~/grass/rzeki/
I have the problem with line
....
v.db.connect -o map='red_'$k driver=dbf database=~/$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/ table='cont_'$k key=cat layer=1
.....
I recive error:

warning:Cannot open database '~////dbf/'
warning:Cannot open database '~////dbf/' by driver 'dbf'
error:Table <cont_lutynia> not exist in database <~////dbf/>

it looks like if script is started from different directory it don't see variables? or something dffernt?
JArek

Jarekj wrote:

in the script, which is started from ~/grass/rzeki/
I have the problem with line
....
v.db.connect -o map='red_'$k driver=dbf
database=~/$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/

The '~/' at the front of the path shouldn't be there.

Also, you need quote the argument; the DBF driver performs run-time
substitutions of GRASS variables. Without quoting, the shell will try
to expand them, and they aren't defined. IOW:

  'database=$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'

Note: you need to use single quotes, as the shell will expand
variables inside double quotes.

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

Glynn Clements pisze:

Jarekj wrote:

in the script, which is started from ~/grass/rzeki/
I have the problem with line
....
v.db.connect -o map='red_'$k driver=dbf database=~/$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/
    
The '~/' at the front of the path shouldn't be there.
  

It was added by me because in first case (without ~/) I thought that the reason is in inappropriate path to table, I forgot to remove it during copying

Also, you need quote the argument; the DBF driver performs run-time
substitutions of GRASS variables. Without quoting, the shell will try
to expand them, and they aren't defined. IOW:

  'database=$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'
  

Yes, that was the reason, thanks!

Note: you need to use single quotes, as the shell will expand
variables inside double quotes.