Difference between revisions of "Lesson 8"
(Added a glossary link to Action~) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | Linux / Apache / GT.M / Web Application Lesson 8. | + | Linux / Apache / GT.M / Web [[Application~|Application]] Lesson 8. |
− | By Ben | + | By Ben Irwin, |
Copied from: http://www.doggiedudes.com/fscc/list.htm | Copied from: http://www.doggiedudes.com/fscc/list.htm | ||
Line 42: | Line 42: | ||
<body> | <body> | ||
− | <form method=post action="../cgi-bin/libr8c.cgi"> | + | <form method=post [[action~|Action]]="../cgi-bin/libr8c.cgi"> |
<p>Full Name: <input type=text name="fullname" size="20"></p> | <p>Full Name: <input type=text name="fullname" size="20"></p> | ||
<p><input type=submit></p> | <p><input type=submit></p> | ||
Line 50: | Line 50: | ||
------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ||
− | The line with, action="../cgi-bin/libr8c.cgi, may need to be changed to match your individual setup. | + | The line with, [[action~|Action]]="../cgi-bin/libr8c.cgi, may need to be changed to match your individual setup. |
The ../cgi-bin notation means to start in the current directory, where you found this web page, move back one directory (..) then move forward to the cgi-bin directory. | The ../cgi-bin notation means to start in the current directory, where you found this web page, move back one directory (..) then move forward to the cgi-bin directory. | ||
− | In my installation my web pages are stored in the /var/www/html directory and my cgi scripts are stored in the /var/www/cgi-bin directory. So my action command moves back from /var/www/html to /var/www then moves forward to /var/www/cgi-bin to look for the action script. The process really doesn't care about what the leading directory structure is, just the relative directories of the html and cgi-bin directories. | + | In my installation my web pages are stored in the /var/www/html directory and my cgi scripts are stored in the /var/www/cgi-bin directory. So my [[action~|Action]] command moves back from /var/www/html to /var/www then moves forward to /var/www/cgi-bin to look for the [[action~|Action]] script. The process really doesn't care about what the leading directory structure is, just the relative directories of the html and cgi-bin directories. |
Place the following cgi script in the cgi-bin directory of your installation. | Place the following cgi script in the cgi-bin directory of your installation. |
Latest revision as of 18:50, 24 July 2012
Linux / Apache / GT.M / Web Application Lesson 8.
By Ben Irwin, Copied from: http://www.doggiedudes.com/fscc/list.htm
Tutorial Home: M Web Tutorials Prev: Lesson 7 Next: Lesson 9
In this lesson we are going to look at standard input. In the Unix and Linux world standard input is where the computer would normally expect input to come from. Standard input in an interactive session comes from the keyboard, where the user is required to input the data at the keyboard. The following short script demonstrates this by asking for name then printing the name back to the screen.
libr8a.cgi ------------------------------------------------------------------------ #!/bin/sh echo "Please enter your name:" read xxxx echo "Thank you, you entered:" echo $xxxx ------------------------------------------------------------------------
Place this routine in your Apache cgi-bin directory. Then run the routine as shown below and you should get similar results.
[root@Mandrake cgi-bin]# ./libr8a.cgi Please enter your name: Ben Irwin Thank you, you entered: Ben Irwin
You name should be different then mine. At least I hope there is only one of me in the computer industry.
A web server will answer the standard input request of a called cgi script with the information from a web page form. The next routine listing is a simple web page with a form asking for your name. This file should be place in your web server document directory. On my system that is: /var/www/html
libr8b.htm ------------------------------------------------------------------------ <head> <title> Lesson 8 Input Form </title> </head> <body> <form method=post Action="../cgi-bin/libr8c.cgi">
Full Name: <input type=text name="fullname" size="20">
<input type=submit>
</form> </body> </html> ------------------------------------------------------------------------
The line with, Action="../cgi-bin/libr8c.cgi, may need to be changed to match your individual setup.
The ../cgi-bin notation means to start in the current directory, where you found this web page, move back one directory (..) then move forward to the cgi-bin directory.
In my installation my web pages are stored in the /var/www/html directory and my cgi scripts are stored in the /var/www/cgi-bin directory. So my Action command moves back from /var/www/html to /var/www then moves forward to /var/www/cgi-bin to look for the Action script. The process really doesn't care about what the leading directory structure is, just the relative directories of the html and cgi-bin directories.
Place the following cgi script in the cgi-bin directory of your installation.
libr8c.cgi ------------------------------------------------------------------------ #!/bin/sh read xxxx echo "Content-type: text/html" echo echo "<html>" echo "<head>" echo "<title>" echo "Lesson 8 Form Report." echo "</title>" echo "</head>" echo "<body>" echo $xxxx echo "</body>" echo "</html>" ------------------------------------------------------------------------
Aim your browser to your web form page using something like the following.
http://mandrake/libr8b.htm
Enter your name into the text box and click on the submit button.
The libr8c.cgi shell script will read the information sent as standard input from the web server into variable xxxx.
It will then set up a simple web page and print the value defined in the variable xxxx.
The value defined in the variable xxxx is a name / value pair. In this case it should return something like. fullname=Ben+Irwin
Tutorial Home: M Web Tutorials Prev: Lesson 7 Next: Lesson 9