CGI FAQ List
Topics
- What is a CGI?
- Commonly used languages
- Unsupported development mechanisms
- Location of commonly used utilities
- What does Permission Denied mean?
- What does Malformed Header mean?
- Where can I find the error logs for my CGI?
- Where can CGIs be run from?
- What will the URI for my CGI be?
- CGI-BIN and multihomes
- How do I get an CGI directory on sonic.net?
- How do I get CGI help?
Answers List
What is a CGI?
The Common Gateway Interface (CGI) is a mechanism for sending information from an end-user's web browser to a program on the web server. CGI also allows for the program's output going back to the end-user's web browser for display.
Common usage for the term "CGI" is in reference to a program that takes input from a web browser and does something with it. Common uses for CGIs include web guestbooks, search engines, and shopping cart software.
Commonly Used Languages
There are a number of languages that can be used to write a CGI. The following are some of the more popular languages that our web servers support.
Perl
Perl is a widespread scripting language that has rather firmly entrenched itself into the internet. Our web servers run Perl 5.005_02 (view full info). The Perl interpreter itself is located at /usr/local/bin/perl
PHP
PHP: Hypertext Preprocessor (PHP) is used as an alternative to Microsoft's Active Server Pages (ASP) technology. Our webservers use PHP version 4.4.8 (view full info) with the interpreter located at /usr/bin/php
PHP 5.2.6 is available as a CGI by inserting a new line at the beginning of the PHP script containing "#!/opt/php5/bin/php" and nothing else (view full info for PHP5). Use the .cgi file extension for PHP5 scripts.
Python
Python is a strongly object-oriented programming language that is becoming increasingly popular with web programmers. Our webservers use Python version 2.3.4 with the interpreter located at /usr/bin/python
C/C++
One of the most broadly-used programming languages of all time, programs written in C or C++ are most often compiled into self-sufficient executable files.
Unsupported development mechanisms
The Sonic.net webservers do not support CGI-style programs written in the following formats:
- Microsoft Active Server Pages (ASP)
- Java Server Page (JSP)
- Cold Fusion
Location of commonly used utilities
What does Permission Denied mean?
Permission Denied is an error that is triggered when a program tries to do something it is not allowed to, or when a web browser requests a file that it is not allowed to use
If you are getting this message on a page or script that you own, then you probably need to change the permissions on that file. Just login to your shell account and do the following:
- type:
cd /path/to/file/ - then type:
chmod 755 filename - then:
exitto leave the shell.
Most Mac and Windows FTP programs will allow you to change file modes (permissions) as well, so shell access is not strictly required to modify permissions.
Advanced information on Modes.
- type:
What does Malformed Header mean?
A malformed header is a general error that means that your CGI did not execute properly. This can be caused by an improper type declaration in your program's output, or even by a syntax error in the program itself.
Missing semicolons and incorrectly uploaded files are common culprits. Double-check the source code for errors and try again.
Where can I find the error logs for my CGI?
The error logs for each of our web servers are located at
/var/log/custweb/error.log. Inspecting the error logs can be very helpful in tracking down the causes of CGI problems in general.Where can CGIs be run from?
Depending on what your program needs to do, there are a number of directories you may want to place it in on our web server.
/home/WWW_pages/username/
This is your default web directory, where your HTML and image files are likely to be located. Most CGIs can function just fine in here alongside the rest of the files for your website.
/usr/local/lib/httpd/cgi-bin/username/
This is the CGI-BIN directory. It has special characteristics that are advantageous for CGI wrapping.
When do I need to use the CGI-BIN?
If your CGI needs to access our server with your file permissions (as opposed to the permissions on an anonymous web-user) you will want to place your files in the CGI-BIN directory.
More information on the use of this special directory is available at our CGI-wrap FAQ
What will the URI for my CGI be?
Files in your default web directory will be accessible on the web at http://www.sonic.net/~username/filename
Files in your CGI-BIN directory will be accessible on the web (unwrapped) at http://www.sonic.net/cgi-bin/username/filename
Files wrapped in your CGI-BIN directory will be accessible on the web at http://www.sonic.net/cgi/username/filename
CGI-BIN and multihomes
If you have a multihomed domain name, you can still use the CGI-wrapping mechanism provided by the CGI-BIN directory. All content in your CGI-BIN directory is also accessible at http://www.domainname.tld/cgi/username/filename where it will be handled just as if it had been requested from http://www.sonic.net/cgi/username/filename
How do I get an CGI directory on sonic.net?
You can use the Servers Directories page to make your WWW, CGI, and FTP directories.
How do I get CGI help?
You can start by posting your questions to the sonic.help.cgi newsgroup.



