|
|
Home
| Tutorials
|
Reference Desk | Books |
Add A
Script | About Us |
Advertising Info |
Warning: main(exec/PHP/date.php3) [function.main]: failed to open stream: No such file or directory in /home/cgiextre/public_html/extras/Tips_Tutorials/General_CGI_FAQ.html on line 68
Warning: main(exec/PHP/date.php3) [function.main]: failed to open stream: No such file or directory in /home/cgiextre/public_html/extras/Tips_Tutorials/General_CGI_FAQ.html on line 68
Warning: main() [function.include]: Failed opening 'exec/PHP/date.php3' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cgiextre/public_html/extras/Tips_Tutorials/General_CGI_FAQ.html on line 68
|
|
| |
| WHAT
IS CGI? |
|
CGI
stands for Common Gateway Interface, and is a standard way
of running programs from a Web server. CGI programs, also
known as CGI scripts are most commonly used to generate pages
dynamically or to perform some other action when someone fills
out an HTML form and clicks the submit button. CGI scripts
are commonly written in a programming language known as Perl,
but can also be written in C+, C++, or any other or any other
compiled or interpreted language. |
|
| HOW
DO I USE CGI? |
|
In
order to take advantage of CGI, you need to have web space on a
server that supports Perl. Most of the free web site places
like Tripod, Geocities do not support CGI scripts. The
same is true for many of the nationwide ISP's like Prodigy, AOL,
MSN, and CompuServe. If you want a CGI capable website,
you will need to pay for hosting through Web Hosting
company. Almost all Web Hosting companies support CGI
scripts. Hypermart,
a free online business hosting company supports CGI scripts and SSI
and
will host your site free of charge. The only catch is you
have to be a business and Hypermart will put ads on your pages
unless you pay for ad-free hosting. But it's still a good, free place to practice your
CGI Kung-Fu! |
| |
| WHERE
DO I PUT MY CGI SCRIPTS? |
|
You
should have a directory called cgi-bin and this is where
you'll want to put your CGI scripts. If you do not have a
cgi-bin directory, you will need to make one and set the
permissions to accordingly used the chmod command. You
might want to check with you hosting company regarding the
proper permissions of the cgi-bin directory, and cgi scripts,
but in most cases, setting the permission to 755 should be
sufficient. Most scripts come with documentation regarding
what the permissions should be for each file. Incorrect
permissions can result in the script not running properly.
Additionally, some web servers require that
all your cgi scripts end in .cgi or .pl, while with other
servers, you can use both .pl and .cgi interchangeably. You might want to check with your hosting company regarding what
extension their server will treat as an executable cgi
script. |
|
| WHAT
ARE FILE PERMISSIONS? |
|
Every
file on your web server has permissions set on it. Permissions
tell the server which files are allowed to be written to, read
from, or executed by which users. There are three different
parts of file permissions:
Owner
- this is defined as the person who created the file. All of the
files on your web site are owned by you.
Group
- a list of other users in your "group". These
permissions should be set the same as "world".
World
- this is basically anyone else. Anyone accessing files on your
web site with their web browser is considered "World".
There are
three different types of permissions that can be give to each
part. The permissions are:
Permission to
execute the file
Permission to
write to the file
Permission to
read from the file
The
permissions can be referred to as numbers (such as
"755"). The first digit is the owner's permissions,
second is the group's, and third is the world's. The permission 755
for example gives the owner permission to read from, write to,
and execute the file, and gives the group and world permission
to execute and read from it. The number '1' represents execute
permission. The number '2' represents write permission. And the
number '4' represents read permission. For more than one
permission, the numbers are added. So, for example, '7'
represents read, write, and execute permissions (4+2+1=7). The
number '5' represents read and execute permission (4+1=5). CGI
scripts need to be set to 755, because the world/group
needs to be able to read from it and execute it (4+1). Files
that are used by the script need to be set to 644 so that
the world/group has permission to read from it. Files written to
by a script need to be set to 777. Directories that a
script creates new files in need to be set to 777 also. |
|
| WHAT
IS CHMOD? |
|
CHMOD
is a Unix command for CHanging access MODe and it is used to
give permission to read write and/or execute files. The CHMOD
settings used for these scripts are derived from the binary
conventions for the three groups; Owner, Group and Other
(World):
4
= Read permission only
2 = Write permission only
1 = Execute permission only
0 = no permissions
For a visual chart on CHMOD
permissions click
here. |
|
| UNIX
OR NT? |
|
You
will notice that the majority of the scripts available only
mention Unix for the platform that they will run on and not
Windows NT. Does that mean that these scripts will only
run on Unix? Well, not really. What it means was the
author of the script wrote the script to run on a Unix server
and it has been tested only on a Unix server. In theory, many
scripts that were made for a Unix sever will run on Windows NT with a
little bit of modification. This FAQ will not go into what
modifications are necessary to convert a Unix designed script to
NT, but the information is available on the web and in support
forums. |
|
| WHERE
IS PERL? |
|
The
first line of any CGI scripts is pointed to the location of Perl
on your web server. The location for Perl on most servers
is /usr/sbin/perl , but this can vary from server to
server. If you have telnet access to your web server, you
can type in which perl at the command prompt and the location of
Perl will be revealed to you. If you do not have telnet
access, you will need to review the FAQs for your web server or
contact your hosting company. |
|
| WHAT
IS SSI? |
|
Many
of the scripts say that they require SSI or Server Side
Includes. SSI is a web server feature that allows a CGI
script to be run and its content displayed every time a html
document is requested. For example, you can use SSI to
implement a counter into your website. Everytime a user
requests the page with the SSI tag for the counter, the counter
script runs, adds the user's "hit" to the counter
total and displays the script's output, which is the total hits
fro that page. But SSI doesn't just do counter's, it can do banner
ads, random messages, and a whole lot more. It can take a
static webpage and make its content dynamic and changing with
very little effort.
In
order to use SSI in your website, you must have SSI available on
your web server. It's best to contact your web hosting
company for this information. In addition, some servers
require that
your html pages end with the extension .shtml instead of the
standard .html or htm.
SSI
are included in a HTML document using tags that look like this:
<!--#exec
cgi="/cgi-bin/mycgi.cgi" -->
Any where
that this tag appeared in your web page, the server would execute
the mycgi.cgi script and include its output.
There is a
lot to be said about SSI, and this minute summary only mentions
a fraction of what can really be done with SSI. For more
information, be sure to check out:
http://www.apacheweek.com/features/ssi |
|
|
|
|
|
|
|
| -
Copyright
© 1999 CGI Extremes, All Rights Reserved - |
|