1st Singapore Web Hosting
> Web Site Hosting
Super-charge Your Web Site With CGI Scripts
A lot of people have web sites but most feel that
CGI scripts are "over their head". Not True! If
you know basic HTML and know how to use FTP programs like WS_FTP
to upload files, chances are you can
supercharge your web site with a CGI script in about 30 minutes.
I'm not talking about writing CGI scripts. All you
have to know is how to use CGI scripts. That's the purpose of this
With so many free
CGI scripts available on the Internet, you are really limiting
you are not using the CGI capabilities offered by your web
With CGI scripts, you can make your site more
interactive with varies functions. You can communicate with
visitors or customers much faster and easier. You can put your
online business onto autopilot.
How does CGI script work?
You've most probably visited web pages and seen "cgi-bin"
appear in the location bar of your browser. CGI stands for
"Common Gateway Interface". When you see that "cgi-bin"
appear in the location bar, you probably executed a CGI script when you requested
CGI is utilized
by placing an appropriate tag in your HTML code. If you download
free CGI scripts from trustworthy sources on the Internet, the author of the scripts
should provide you with the appropriate HTML tag needed to run
that script. Look for readme file in the downloaded files.
When the page is requested by a browser, the server
reads the tag, locates and executes the script file that's specified by the tag, and puts in the tag's
place the results of the execution of the script.
If you've ever looked at your browser's settings, you've probably
and Java but haven't seen anything for CGI. That's because
It just gets pure HTML from the server after the scripts are
CGI and Perl
More than often you see the term "Perl" used
together with the term
"CGI". The two are not the same.
CGI is the process by which scripts are run. CGI programs, or
scripts, can be written in a variety of computer languages
including C. Perl
is the most common language used for writing CGI
In practice, more than 90% of CGI scripts are
written in Perl.
Three Steps To Using A CGI Script
Once you've downloaded the script you want to use, there are three
basic steps you need to take in order to use the script on your
- Set any options or parameters that the script may need
- Transfer the script files (the script itself and any
necessary data files) to your server and set the correct permissions
- Add the script's HTML tag to the page(s) you want to use the
"Setting Options" in scripts is typically just a matter
of opening the .pl (or .cgi) file in a text editor and entering
values for some of the scripts variables. For example, you may
need to enter your email address if the script sends email
notifications of some event.
Perl scripts typically have a .pl extension, but
they may have a .cgi extension instead sometimes. It doesn't
really matter. Files with other
extensions, or no extensions, will likely be data files used by
the script. Most script programmers will also include a readme
file that contains information about the script and how to set it
More complex scripts may have more than one .pl file which
require different HTML tags for each one. It's also possible that
one script may "call" another script so that only one
tag is needed. Also, look for additional .pl files
with names like config.pl or cfg.pl. These are
script files where all of the user-settable options are entered
and stored. If a file like this is included in the downloaded file,
you typically don't have to open the main script file to set
options. The main script will refer to this configuration script
each time it is executed.
All of these files are typically combined into a single
Some hosts may require that scripts must have a .cgi extension. It is normally not a problem to
just rename the file to comply. If you do so, remember to change
the extension in the HTML tag also.
Perl scripts are simply plain ASCII text
files. Besides codes for web server, the programmer can also put
comments and instructions in the script that users can understand.
It is easy to spot these information that is meant for you to read
because the line will start with # character.
The # character is the "comment"
character in Perl. Any line that begins with a #
does not get executed by the server.
You can simply use a text editor like Notepad to open the
main, or if found the configuration, .pl file and check the top of
the file for any information or setup instructions. If there is a readme
file, open that in a text editor and look for setup instructions
The very first line of any Perl script is a user-settable
option and is always going to be the path to your server's Perl
installation, preceded by the characters "#!".
This line is commonly referred to as the "shebang".
Typical shebangs can be:
- #!/usr/bin/perl (often the Perl
- #!/usr/local/bin/perl (often the
Perl 5 location)
Setting options usually involves entering
values for script variables. These values can be a '1', 'Y', 'y',
'YES', etc. to enable an option and a '0', 'N', 'n', 'NO', etc. to
disable it. Certain user or system information may be needed for
some variables. You may be asked to enter path information or an
The comments in the script or the readme file should clearly indicate what the option is and
what the valid optional values are.
Transfer Files And Set Permissions
Click here to continue
Feel free to use this article in your
publication or web site.
It's pre-licensed to you.
The only requirement is to include this resource box:
Article by Zac Hewlett at
web site design and promotion articles, proven online
marketing tips and techniques.
More Web Site Hosting Articles