|
CGI Shell scripts and ISINDEXThe HTML ISINDEX tag has ben around since the dawn of interactive web scripting but has been depricated in favor of newer CGI constructs. This tutorial covers the use of Bash or Bourne shell scripts and the HTML ISINDEX tag to generate dynamic content.Also see our tutorial using more current CGI scripting constructs with the Bash shell: Bash shell CGI tutorial
|
| | Home Page | Linux Tutorials | Terms | Privacy Policy | Advertising | Contact | | |||
|
Related YoLinux Tutorials: °Apache Web Server Configuration
Free Information Technology Magazines and Document Downloads |
This tutorial covers the basics of using bash shell scripts for web server CGI. Default Red Hat Linux directory configurations for Apache are used in this tutorial. The HTML ISINDEX tag is used for data input to the script. CGI uses two methods to pass data between the browser and the web server, GET and POST. The GET method passes data in the URL and is the method employed here. The web server will pass environment variables into the execution environment of the CGI shell script which also may be used.
CGI Shell script to output a text page: /var/www/cgi-bin/cat-a-text-page
Useage: <A HREF="/cgi-bin/cat-a-text-page?/home/user1/public_html/text-file.txt">Text of link</A> Note that the permissions on the shell script must changed to make the script executable: chmod +x cat-a-text-page
CGI Shell script: /var/www/cgi-bin/Output-text-as-html
Useage: <A HREF="/cgi-bin/Output-text-as-html">Text of link</A>
The Web Page:
HTML Source:
The following will get generated: http://localhost/cgi-bin/catpage?%2Ftmp%2Ftext-file.txt The CGI will then spit out the text page specified. [Potential Pitfall]: Currently Mozilla 1.2.1 (Also default Red Hat 8.0 and 9.0) browsers have a bug which prevents this from operating properly. Konqueror, Netscape, Lynx all work properly.
In this case the script will generate all displayed interfaces. This example is the easiest form of a simple on-line database. (Grep/search a file and output the results of the search)
CGI Script:CGI Shell script: /var/www/cgi-bin/isindex-search
Results:
The web server will execute the CGI script in its own process space but will set some usefull environment variables. To view these use the following script: /var/www/cgi-bin/env.sh
Test: http://localhost/cgi-bin/env.sh Output: (example for Red Hat 8.0)
|
|
|
YoLinux.com Home Page
YoLinux Tutorial Index | Terms Privacy Policy | Advertise with us | Feedback Form | Unauthorized copying or redistribution prohibited. |
|
|
Copyright © 2002, 2003 by Greg Ippolito