|
CGIFAQ
Domain
Name Registration Service FAQ
Website Hosting Service FAQ
E-Mail FAQ
Security FAQ
URL Forwarding Hosting
Service FAQ
Control Panel/Passwords FAQ
FTP FAQ
CGI FAQ
MySQL FAQ
What
are CGI scripts?
CGI (Common
Gateway Interface) is a process used by the server to pass information
between the user and an application on the server. With CGI access, you
can install Perl scripts on your website for such things as feedback
forms, guestbooks, counters, and so on.
What
information and server paths do I need to run a CGI script?
CGI scripts must
be run from the cgi-bin directory which is outside the public_html
directory. CGI scripts need to have a .cgi or .pl extension. PHP scripts
need to have a .php extension.
cgi-bin relative path = /cgi-bin/yourscript.cgi
cgi url = http://www.yourdomain.com/cgi-bin/yourscript.cgi
path to Perl = /usr/bin/perl
path to sendmail = /usr/sbin/sendmail
path to the date program = /bin/date
Do you
know where can I find some free CGI scripts?
Here are a few
resources for CGI scripts:
HotScripts
FreeCode
The CGI Resource Index
Free-Scripts.Net
Script Search
My CGI
script is not working, can you help me with it?
Our support does
not cover CGI script debugging. We consider this a function of web design
and we do not currently offer any in-house web development or consulting
services.
Here are a few
things to try when you are troubleshooting a CGI script:
First of all,
thoroughly read through the instructions that came with the script and
also check the website where the script was downloaded for troubleshooting
info and user forums. Make sure that you have uploaded your script
to your cgi-bin which is one level up from your public_html directory.
Check to see if
the script was uploaded to the server in the proper format (ASCII not
binary).
Make sure that
there are not any DOS/Windows carriage returns (i.e., ^M) at the end of
each line in the script. This is usually caused by a text editor or FTP
program that is not properly uploading your script in a Unix/Linux format.
If this is happening, try changing your code line break settings or upload
settings to Unix/Linux.
Here's how this
is done in Dreamweaver: From the menu, goto Edit > Preferences >
Code Format, then change Line Breaks to "LF (Unix)".
The ^M is
actually the ASCII LF character. Windows uses CR/LF, Mac uses CR and UNIX
uses LF as line terminators. Most FTP programs translate the line
terminators when doing an "ASCII" or "text" transfer,
but they do not do the translation if it is a binary transfer. The problem
with CGI files is that the FTP program may not recognize the extension, so
it assumes that it is a binary file. Turning off the auto detect feature
and manually transferring the CGI files as ASCII should solve your
problem. Another option would be to add .cgi/.pl to the list of ASCII file
extensions.
Check script to
make sure that magic comment specifies where perl is located: #!/usr/bin/
perl
Verify that all
the paths are correct, including your public directory path. Do not use
the "www" part of your domain in your public directory path. See
our server paths section for more info.
Check to see if
all the file permissions are set correctly. Permissions can be set using
an FTP program that allows permissions to be set on transfer. Typically
scripts are set to be 755, user: read, write, execute; group: read,
execute; other: read, execute (-rwxr-xr-x), but you should always check
your script instructions or README to be sure.
PLEASE NOTE: For
security purposes, within the cgi-bin, script permissions cannot be set
higher than 755, or user: read, write, execute; group: read, execute;
other: read, execute (-rwxr-xr-x).
If you have checked all the above and are still receiving an
"Internal Server Error" when trying to execute the script, check
the domain's error_log file (on cPanel). Most likely you will see a
"Premature end of script headers" error which usually means that
the file has been corrupted in some way. This can occur when the script is
uploaded or when the script is edited and saved in certain text editors.
Usually the file is corrupted with the (line feed) hidden character which
is commonly mistaken with the (carriage return).
Since installing
a CGI script is extremely difficult for new webmasters, you may want to
consider asking a friend with CGI experience to walk you through the
process or hire a webmaster for this part of your site.
Here are a few
good online articles on installing CGI scripts that might help:
Setting Up A Form
Powered By CGI (SitePoint)
How To Install A Script (About.com)
CGI Scripts for Fun and Profit (webmonkey)
The Common Gateway Interface (NSCA)
Finally, if all
else fails, you may want to consider using a PHP script.
I'm
having difficulty setting up CGI scripts, are there any other
alternatives?
Yes, check out
PHP. It is much easier to configure (no permissions to set, it can run
from any directory, etc.) and much of what you can do with a CGI script
you can do using PHP. The development community for PHP is gigantic, so
you will see more and more applications that will be using it in the years
to come.
How do
web users setup CGI scripts? Do they need to use a cgi-bin?
Web users (i.e.,
http://domain/~username) do not need to use the site's main cgi-bin. They
can setup CGI scripts to run anywhere within their web space.
|