Wednesday, April 2, 2008

Quick GT.M create a usable database

Using GT.M on Ubuntu.
I just wanted to have a usable database to experiment with.
The location of my new database is going to be '/gtm/gbl/'.
Basically I need to create 2 new files:

  • /gtm/gbl/mumps.gld
  • /gtm/gbl/mumps.dat

First it is important that the environment vaiable 'gtmgbldir' is equal to the global directory file path ('gtm/gbl/mumps.gld').
It can be mannualy set for the purposes of this session using:

user@machine:~$ gtmgbldir=/gtm/gbl/mumps.gld
user@machine:~$ export gtmgbldir
user@machine:~$


The directory '/gtm/gbl' was created by root via sudo:


user@machine:~$ sudo mkdir /gtm/gbl

This means only root can create new files in this directory. This means that the commands to create new files in this directory must also run via sudo.
Change directory to /gtm/gbl;


cd /gtm/gbl/

start the mumps prompt in root:



user@machine:/gtm/gbl$ sudo $gtm_dist/mumps -direct

Start GDE



GTM>D ^GDE
%GDE-I-GDUSEDEFS, Using defaults for Global Directory
/gtm/gbl/mumps.gld

GDE command adapted from manual:



GDE> change -segment default -allocation=1000 -file=/gtm/gbl/mumps.dat


Note that the the file spec contains the full path to the 'dat' file.
This stops mupip later from creating the dat file in your $gtm_dist directory, in the next part.
Now exit GDE:



GDE> exit
%GDE-I-VERIFY, Verification OK

%GDE-I-GDCREATE, Creating Global Directory file
/gtm/gbl/mumps.gld
user@machine:/gtm/gbl$

OK now create the 'dat' file in root mode:



user@machine:/gtm/gbl$ sudo $gtm_dist/mupip create
Created file /gtm/gbl/mumps.dat
user@machine:/gtm/gbl$

List the contents and permissions of the gbl directory:



user@machine:/gtm/gbl$ ls -l
total 60
-rw-rw-rw- 1 root root 1092096 2008-04-02 06:09 mumps.dat
-rw-r--r-- 1 root root 1024 2008-04-02 06:07 mumps.gld
user@machine:/gtm/gbl$

Change the permissions on the 2 new files to open read and write



user@machine:/gtm/gbl$ sudo chmod 666 mumps.*
user@machine:/gtm/gbl$

This will allow mumps to be run under the normal user account and facilitate reading from and updating the database file.
A small test of the new database.


user@machine:/gtm/gbl$ gtm

GTM>Write $Data(^TEST(123))
0
GTM>Write $Data(^TEST(123))
0
GTM>Set ^TEST(123)="abc"

GTM>Write $Get(^TEST(123))
abc
GTM>Halt
user@machine:/gtm/gbl$

Note - Because the environment variable 'gtmgbldir' is set to '/gtm/gbl/mumps.gld' in the user local profile, whenever a mumps direct session is started, it will be using the above new database.

No comments: