[GRASS-user] Setting GRASS environment variable in a C program - step two

rabotin rabotin at supagro.inra.fr
Thu May 27 11:16:55 EDT 2010


If (inside a GRASS session), I access with  v.db.connect -p map=GU0507
it looks ok :

Vector map <GU0507 at simon9> is connected by:
layer <1> table <GU0507> in database 
</home/rabotin/grassdata/Roujan/simon9/dbf/> through driver <dbf> with 
key <cat>

Do you know how to launch a grass command (e.g. v.db.connect) inside a C 
script
I try this line in my C progam

system(v.db.connect -p map=GU0507)

but I have an error message

sh: v.db.connect: not found

Michael R



Glynn Clements a écrit :
> rabotin wrote:
>
>   
>>> 	std::cout << driver << std::endl;
>>>       
>> And I got a zero value return . So my driver isn't set ?
>> Is the problem from the following lines :
>> setenv("DBF_DRIVER","dbf",1);
>> setenv("DB_DATABASE","$GISDBASE/$LOCATION_NAME/$MAPSET/dbf",1);
>>     
>
> These will be ignored. The default DBMI settings are taken from the
> VAR file, not the environment. But you're use the settings from an
> existing vector map.
>
>   
>> I didn't write but I use grass 6.4 on ubuntu 9.10.
>> Do you know other commands to test or to set the dbf driver than 
>> db_start_driver command ?
>>     
>
> The code looks okay. Can you access the map's attribute table using
> existing GRASS modules, e.g."v.db.connect -p ..."?
>
>   


-- 
*********************************

Michaël Rabotin
Ingénieur d'étude en géomatique

Laboratoire d'étude des Interactions Sol, Agrosystème et Hydrosystème
UMR LISAH SupAgro-INRA-IRD
Bat. 24
2 place Viala
34060 Montpellier cedex 1 
FRANCE

Téléphone :  33 (0)4 99 61 23 85
Secrétariat : 33 (0)4 99 61 22 61
Fax : 33 (0)4 67 63 26 14
E-mail : rabotin at supagro.inra.fr

*********************************



More information about the grass-user mailing list