CGI Scripts
From Campus Web Server Help
Contents |
Overview
CGI scripts provide a powerful facility for interactivity in your website. They are programs that can handle input from forms, output system properties such as the current time, store data to files, send email, and much more. We also have a resident interpreter (mod_php) for PHP scripting. Unlike CGI, such scripts can be executed from your public_html directory directly. Most CGI scripts on our server are probably written in perl or python, whose current version you'll find on the Main Page.
Availabilty
With the power of CGI comes increased security risks to the server, which provides space not only for you, but thousands of maintainers. Hence, they are not enabled by default. To have CGI enabled, please contact the EITS Helpdesk. Once you have the script enabled, please use safe coding practices to help everyone avoid disruption of service.
How To Make CGI Scripts Work on Your Site
Location and Permissions
Your CGI scripts should reside in "cgi-bin" under your home directory. If the directory doesn't exist, CGI has probably not been enabled for your account (follow the instructions above to enable CGI).
Set the permissions to 755.
chmod 755 yourscript
When set properly, the permissions will look like this
-rwxr-xr-x
Ensure that the first line of the script refers to the correct interpreter:
#!/usr/bin/perl
or
#!/usr/bin/python
etc.
Referring To The Scripts In Your HTML
uga.edu Alias Accounts
You have an Alias Account if you access your site from http://uga.edu/username. Though your directory is named "cgi-bin", the main uga.edu site "owns" a master cgi-bin directory, which takes precedence over the one in your home directory. Your cgi-bin directory can be referenced with username-bin, where username is your login ID. For example:
<form action="myusername-bin/process.pl">
Virtual Hosting Accounts
You have a virtual hosting account if you access your site by visiting [nowiki]http://username.uga.edu[/nowiki] or similar. CGI is configured by default for most virtual hosts. Most virtual hosts should refer to cgi-bin:
<form action="cgi-bin/process.pl">
Your virtual host may have other ScriptAlias directories (areas where CGI scripts may reside) if a maintainer has specifically asked for a special one in the past. In this case, refer to whatever the ScriptAlias is for your particular directory.
