Lesson 3

From VistApedia
Revision as of 10:52, 5 March 2012 by NeilArmstrong (talk | contribs) (Added glossary link to Prompt~)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Linux / Apache / GT.M / Web Application Lesson 3

By Ben Irwin, 
Copied from: http://www.doggiedudes.com/fscc/list.htm
Tutorial Home: M Web Tutorials
Prev: Lesson 2
Next: Lesson 4

In Lesson 3 we are going to only use our cgi script to take us to the MUMPS environment, then a MUMPS program to write information out to our web browser. We will write out the same thing, but we will use MUMPS commands to perform the writing. Basically we will exchange the shell echo command with the MUMPS (W)rite command.

To get started we will use a Linux shell script to get MUMPS started. Your shell script will probibly look a little different, but I will explain my shell script listed below.

library.sh2

----------------------------------------------------------------

#!/bin/sh
 
cd /usr/local/gtm/VISTA
export gtm_dist=/usr/local/gtm
export gtmroutines="$gtm_dist/VISTA/uo($gtm_dist/VISTA/ur) $gtm_dist"          
export gtmgbldir=/usr/local/gtm/VISTA/mumps.gld
export PATH=$PATH:$gtm_dist
mumps -run ZZLIB2
----------------------------------------------------------------

The line "export gtm_dist=/usr/local/gtm" defines where the general GT.M routines reside.

The line that defines the "gtmroutines" variable, tells GT.M where to look for it's routines.

The line that defines the "gtmgbldir" variable, tells GT.M where to look for it's globals or data files.

The line "mumps -run ZZLIB2" tells the system to run MUMPS and after starting MUMPS to run the MUMPS routine, ZZLIB2. When done running ZZLIB2, return to the Linux command Prompt.

The MUMPS routine would look like what is shown below.

----------------------------------------------------------------

ZZLIB2  ; Hello world web routine.
       ;
       W "Content-type: text/html",!!
       W "<html>",!
       W "<head>",!
       W "<title>",!
       W "Hello world demo.",!
       W "</title>",!
       W "</head>",!
       W "<body>",!
       W "Hello world, for the second time!",!
       W "</body>",!
       W "</html>",!
       ;
       Q

----------------------------------------------------------------

Now if you return to the cgi-bin directory and run the library.sh2 shell script using one of the following methods.

library.sh2 or ./library.sh2

You should receive the following.

----------------------------------------------------------------
Content-type: text/html
<html>
<head>
<title>
Hello world demo.
</title>
</head>
<body>
Hello world, for the second time!
</body>
</html>
----------------------------------------------------------------

Then if you open your browser and point it to the library.sh2 shell script on your Linux server using a line something like.

http://10.0.1.209/cgi-bin/library.sh2

You should receive a web page that looks like.

----------------------------------------------------------------

Hello world, for the second time!

----------------------------------------------------------------
Tutorial Home: M Web Tutorials
Prev: Lesson 2
Next: Lesson 4