Lesson 2

From VistApedia
Revision as of 18:47, 10 October 2006 by Forummgr (talk | contribs)
Jump to: navigation, search

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

Tutorial Home: M2Web Tutorials
Prev: Lesson 1
Next: Lesson 3

In Lesson 1 we placed the following cgi script file in the cgi-bin directory for our web server. When we called it using the web server it just wrote "Hello world!" to the web page and put the title "Hello world demo." in the web browser title bar.

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>"

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

If we run the cgi script from the Linux prompt using the following command: library.sh1 or ./library.sh1 depending on your Linux setup you should get the following listing.

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

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

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

The "Content-type: text/html" line tells the browser to treat this document as a html file.

Html tags usually go in pairs one to start a section and another to end a section.

The <HTML> tag starts the html page. The </HTML> ends the html page.

The <HEAD> tag starts the header section. The </HEAD> tag ends the header section.

The <TITLE> tag starts the title section. The </TITLE> tag ends the title section.

Well, I guess you get the idea.

The important concept to learn from this lesson is that what prints to the screen when a cgi script is run at the Linux prompt is the same information that gets sent to the web browser.

Tutorial Home: M2Web Tutorials
Prev: Lesson 1
Next: Lesson 3