If you're confused about the difference
, here's a quick explanation that might help:
by Netscape in 1995 as a way to extend the capabilities of web browsers and
It was originally called Mocha, then LiveScript, and finally
(the name helped promote Sun's Java programming language, though it really
paying Sun any licensing fees they called it JScript. These days,
it compiles the script and executes it on the spot, displaying the
results in a browser (for example, a live date on a web page).
CGI Scripts, on the other hand, are stored in the cgi-bin of
a web server (or some other area of the web server that's been set aside
to run scripts).
Most CGI scripts are written in Perl, which is a full-blown programming
language that was first invented in 1987 and which has many uses
outside web servers (eg: in graphics programming, system administration etc).
However, scripts can also be written in other programming languages such
as C, C++ or Microsoft's ASP
Instead, calls to the scripts are pasted into web pages (usually as
And when the script is called (eg: by clicking a link or pressing a button
on a form), the web server's CGI-bin will run the script and display any
results on the screen as a HTML page (eg: "Thankyou for submitting this form")
added by simple cut-and-paste. The main problems that can occur with
several upgrades over the years to patch security holes that existed in earlier
versions) and conflicts that may be caused by running several scripts
on the same page.
Perl scripts, by contrast, are usually more difficult to set up because
you'll need to specify the path to the Perl interpreter on your web
server; upload the script to your cgi-bin after you've set the path
in the script; set web server permissions if you're running on a
Unix/Linux web server (as most people are); and then test and modify the
script until you're happy with it.
blog, database etc). This is because Perl is a fully formed programming language
Furthermore - because Perl scripts are executed on your web server
rather than in a visitor's browser - they're also more reliable
they can't turn off a Perl script).
way to make your site come
alive. Whether it's a guestbook, a light-bar menu, messages in your browser's
status bar, pop-ups or live dates, they're all pretty easily accomplished
with one or the other.
Even better, there are now many superb sites on the Internet which
allow you to cut and paste pre-written, fully tested scripts for
So you don't need to be a rocket scientist to use them. And you don't
understanding of how they both work is usually good enough).
has evolved and improved quite a lot over the years.
try to test your scripts under the latest releases of Internet Explorer
and Firefox (which - between them - account for about 98% of
the browser market).
likely that it will work for the overwhelming majority of your web site visitors
CGI scripts, though (which are most commonly written in the Perl language),
will work equally well with all browsers. This is because they're
executed on your web server rather than in a visitor's browser
when a web page loads (see our sidebar story for a quick explanation
below. But if you find one we've overlooked, then please
tell us about it. We'll
be happy to add it to the list.
Dynamic Drive is a marvellous source of pre-tested, reliable
browsers. It also has lots of tips, tricks and expert advice too (including
page and how you can circumvent the problem). This is a resource that we've
used many, many times over the years and one that we can highly
this is another terrific place to look.
This is another very useful site that also offers hundreds of free
We've found this a useful resource on several occasions, and you might too.
provides a great background on the origins and development of the language.
The Wikipedia entry also has links to many useful related resources in this
W3Schools are the Internet's defacto training school and their very
a great place to start learning about the language.
This site is part of the much larger WebTeacher.Com site and it offers a
to increase your knowledge about how it works quickly, then this excellent
and easy-to-read tutorial can accomplish part of what W3Schools
(above) can do for you in a shorter time (NB: This site also
has a CGI tutorial)
to extend your knowledge, this is a very good reference site and its excellent
tutorials and tips can teach you quite a lot about the more obscure ins and
outs of this simple - but sometimes maddening - programming language.
Cut-And-Paste CGI Script Resources
This very famous site has more than 16 free cut and paste CGI scripts
for adding counters, guestbooks, random image displays, free-for-all
lists and other useful add-ons to your site. Matt's Script Archive is also
the home of FormMail, which is probably the most widely-used script
in the world for processing web forms and emailing you the contents (eg:
a "Contact Us" form). Each script is well documented and very easy set up
and install, but Matt's site also has an FAQs page and a Help Centre if you
need additional assistance.
This CGI Resource Index contains reviews and links to several thousand
CGI scripts in hundreds of categories - anything from freeware offerings
through to full-blown commercial applications. This is probably the single
most authoritative collection of CGI scripts on the Net and the chances
are that if you want to do anything with a script, someone's already programmed
it and you can find it here. The CGI Resources Index also contains listings
for CGI programmers so that if you need to hire some ad-hoc programming
talent for your web site, you can also find Perl programmers here too. We've
use this site many times over the years, and can highly recommend it.
Another terrific script resource we can highly recommend is
HotScripts.Com. Like the CGI Resource Index (above), HotScripts contains
reviews and links to several thousand CGI, ASP and PHP programs along
with many more obscure and/or emerging scripting languages like Python, Ajax
etc. HotScripts list both free and commercial scripts and this is a resource
we've found ourselves turning to many, many over the years. In fact - between
the CGI Resource Index and this site - we've rarely had to venture elsewhere
to find a script to solve any requirement that we've had or our clients have
CGI Script Educational Resources
If you'd like to know the history of Perl, Wikipedia's summary provides
a great background on the origins and development of the language. The Wikipedia
entry also has links to many useful related resources in this area.
Microsoft developed ASP as a proprietary answer to Perl (which is a public
domain programming language). ASP works in a similar fashion to Perl, though,
and Wikipedia's entry provides some details about it, along with relevant
links to other resources if you'd like to find out more.
CGI stands for "Common Gateway Interface", and this academic resource
provides lots of information about how CGI works, including suggested uses
for CGI and how to deal with the potential security problems that can surround
CGI. This site can be useful to both systems administrators and webmasters
keen to extend their knowledge about CGI in general.
This page last updated: 15-Oct-2009