Lesson 1

From VistApedia
Revision as of 14:31, 22 February 2012 by NeilArmstrong (talk | contribs) (Added glossary link to Application~)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Linux / Apache / GT.M / web Application / FileMan and VISTA

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

I am going to provide a little tutorial on this mailing list to introduce the readers to web Applications. We will be using the Apache web server, simple cgi scripts, gradually increasingly complex mumps routines and finally moving to FileMan and VISTA database calls to produce our web Application. Our final project will be a web Application to catalog books, videos, and magazines.

Disclaimer: This is only a tutorial. I will be using techniques that may not be secure for an open internet solution. I obviously make no warranties regarding the programs or techniques. Be sure to read the responses to this e-mail tutorial, I am sure that the more security aware readers will share their understanding and wisdom. I invite everyone's input. It will make the process more of a learning experience.

Ok here we go. Lesson 1 - Linux / Apache / CGI Scripts and the great "Hello world" program.


Most Linux installations come with an Apache web server. It is beyond the scope of this letter to explain how to get the web server up and running.

Note: You can check your Package Manager or Add/Remove Software to see if Apache is installed. The program itself is httpd, it is started with apachectl, and you will need the cgi-bin directory. You can locate these with

$ find / -iname httpd
$ find / -iname apachectl
$ find / -iname cgi-bin

To manually start Apache (until the next reboot), become root and invoke apachectl:

$ su - root
Password: 
# apachectl start

To test it, open a browser and type "localhost" into the address. You should get an Apache splash page. Run "apachectl stop" and reload the browser webpage; it should be "Unable to connect". Further documentation is at Apache.org. End of note.

We are going start in the cgi-bin directory to produce our CGI script.

On my Linux / Apache installation the default place to write cgi scripts is in the /var/www/cgi-bin directory.

We are going to create a cgi script that will produce the single statement "Hello world!" on a web page. The name of our file is going to be "library.sh1".

 library.sh1
 ----------------------------------------------------------------
 #!/bin/sh


 
 echo Content-type: text/html
 
 echo  
 echo "<html>"
 echo "<head>"
 echo "<title>"
 echo "Hello world demo."
 echo "</title>"
 echo "</head>"
 echo "<body>"
 echo "Hello world!"
 echo "</body>"
 echo "</html>"
 
 ---------------------------------------------------------------

Now make the permissions to the file so that they include executable permissions.

 chmod 777 library.sh1
 
 -rwxrwxrwx 1 apache   apache   211 Aug 20 19:32 library.sh1*

Now aim your browser to your new cgi script using something similar to the following line. Change "localhost" to the IP address of your own Linux server, if necessary.

http://localhost/cgi-bin/library.sh1

You should see a web page with the following line.

Hello world!
And the web page header should say "Hello world demo."

Tutorial Home: M Web Tutorials
Next: Lesson 2