Contact Site map Home

Technical Support
(Historical information only. We hope you find it to be a beneficial resource)

CGI Scripts Information


General Information
More Technical Information
CGI Library
Server Side Includes
Example Script
Links to Other Resources

General Information:

Our servers have the capability to run CGI scripts based on Perl, Unix SH, BASH, KSH, CSH, and C/C++ languages. Perl is a our language of choice for most applications as it is a world standard and is well suited to CGI. In addition, Perl code does not require manual compilations whereas C/C++ code must be compiled on our web servers prior to use.*

If you have a custom CGI script that you need to use, simply upload it to your personal "cgibin". 

Here are some helpful tips to follow when installing Perl scripts:

Utilize any directory except "cgi-bin" for your own scripts. We recommend placing them in your cgibin directory to help consolidate them.

Upload in ASCII transfer mode (and NOT BINARY mode) Those using Fetch should use Text mode (not Raw Data)

The first line of each script should read: 

#! /usr/local/bin/perl (please also see below)

One exception is if you are using PerlShop, it should read:

#! /usr/local/bin/perl5.003

Reference the script using "cgibin", NOT using "cgi-bin"

Use ".cgi" extensions for all scripts

If a script calls another file within your account, but the script does NOT require a URL, you need to use the system path.

<- if file resides in root
<- if file resides in cgibin

Substitute the path to the file beginning with your domain name. Your domain name is the directory name of your account.

More Technical Information:

  • Scripts must be made executable with chmod 755 filename
    We have two FAQ's on file permissions in different styles,
    please choose the one appropriate for your level:

        Long Winded
        Really Long Winded

  • Filenames that end with the .cgi extension can be placed anywhere in your site but we recommend placing them in your local cgibin directory to consolidate them. If you need to use a different extension, we can create a Scriptalias for your local cgibin directory (default on new sites) so that any file there will execute (provided perms are set).
  • The path to "sendmail" on our system is /usr/sbin/sendmail
  • Scripts that are to respond to the calling browser with a complete HTML page must have the Content Type tag as the first line of output:

              print "Content-type: text/html\n\n";

    Otherwise, they must be named with the nph- prefix. The nph- stands for non-parsed-headers. For example, let's say date.cgi returns the date as an SSI. So date.cgi becomes nph-date.cgi so it doesn't mess up the rest of the page. Our built-in odometer counter is another example of this.
  • Perl scripts will REFUSE to run if uploaded in "binary" or "raw data" mode from a non-unix computer. Be sure to set your FTP software to "ascii". Mac users should choose "text" mode.
  • For users of Perl 5: the default directory for Perl 5 is at /usr/local/bin/perl. This defaults to Perl version 5.00404*. Users of other versions of Perl 5 should use the path that applies to the version of Perl 5 that they are using. It will be one of the following:

                    /usr/local/bin/perl5.00404   =  /usr/local/bin/perl

*Some newer servers will not have these earlier versions available. In this case, use the default:


  • For users of the PerlShop script, the directory to use is /usr/local/bin/perl5.003*
  • For users of Perl 4: the directory for Perl 4 is /usr/bin/perl4.036* Perl4 scripts usually will need to have any @ or $ escaped with \ character to be perl 5 compatible. i.e., print "webmaster\"*


suexec and permissions:

  • Our system does not use "cgiwrap" but suexec is available.
  • New sites and all FrontPage'98 sites have suexec enabled by default. This will affect the way cgi's are run on your site. It is more secure but requires the user to know a bit more about permissions.
  • Basically, a file executed from a web page with permissions of 755, owned by your userid, has the associated group of bbsuser and is in a directory that has all these same settings, will run under suexec and have access priveleges as if you were running it yourself. This is an example directory listing:
    www#:/mnt/web/guide/domain/cgibin# dir
    drwxr-xr-x 3 user bbsuser 512 May 31 15:20 .
    drwx--x--x 32 user wheel 1024 Jun 3 10:24 ..
    -rwxr-xr-x 1 user bbsuser 5780 May 31 15:20 search.cgi
    -rwxr-xr-x 1 user bbsuser 69392 Jun 3 10:24 cgiemail


CGI Library:

  • We have a central library of CGI's at /web/cgi-bin . Sites without suexec can use the files there as is. A ScriptAlias points all URL references like this :

    to our central library so you can use our cgi scripts and not have to make duplicate copies of the files.
  • Sites with suexec can not operate the cgi's in that library. You can copy any of them to your local cgibin directory and set the permissions as above.
  • You can use any directory other than cgi-bin or icons to store your scripts but we recommend using your cgibin (no hyphen) directory so we can find them if you need help.


Server Side Includes:

  • <!-- Server Side includes --> only work in files with the .shtml extension. The cgi file must have its execute and read public bits on to be run from a browser. The file that contains the include only needs to be readable. Try these commands:
            chmod 755 file.cgi

            chmod 644 file.shtml

  • While you can use a .htaccess file to have the server parse all .htm or .html pages in a directory (and its sub-directories), this will slow the server as it will be parsing some files that do not have SSI's in them. We recommend being very selective if you use this technique. The contents of the .htaccess file would be:

            AddType text/x-server-parsed-html .htm .html
  • You can name your home page index.shtml to use PARSE(Server Side includes) within it or index.cgi to use a script that creates the home page on the fly. Using an index.cgi to read incoming request headers for browser-type is a good use for this technique. If your index.cgi serves pages based on the HTTP_HOST variable, it may be in violation of our parked domain policy. We recommend checking with Tech Support if you are not sure.
  • <!--#exec cgi="mycgi.cgi" --> is a cool way to output the result of a simple cgi script into the middle of somefile.shtml .
  • More detailed information on SSI's can be found at:




  • If you can't figure out why it doesn't work, run it from the command line via telnet, or rename it to nph-Scriptname. You'll see more error messages. Running it with the perl w flag will give even more error messages:

            perl -w   file.cgi

  • The three most common cause for errors are permissions, permissions and permissions.
  • CGI is programming, don't be mistaken into thinking it is as easy as HTML. It isn't.
  • If you are going to use perl, buy a Perl book, please.
  • If you can't figure it out, ask us, we will help you by email on an "as time permits basis".
  • There are many undocumented examples in /web/cgi-bin and /web/cgi-src , however we don't support them until we document them and know they are working.


    Example of a CGI Script: "myfirst.cgi"

    echo Content-type: text/plain
    echo 10 print "HELLO"
    echo 20 goto 10
    echo Hello there I see you saw my page at $HTTP_REFERER
    echo You are using $HTTP_USER_AGENT as a browser.
    echo $HTTP_USER_AGENT >> agentfile.txt
    echo \&lta href=\"\"\> Home \</a\>

    Yawn - Notice the \ escapes, the blank echo after the content-type line. Also If you want to use agentfile.txt line, I had to upload a blank file called agentfile.txt, and then use the file manager to set PUBLIC WRITE on that file. Or the script will not work! (telnet: touch agentfile.txt;chmod o+w agentfile.txt)

    CGI Links:

    O'Reilly & Associates
    - Don't normally recommend books, but in the case of Perl, Unix, Linux, Scripting, etc. your might need to read-up with the best.

    The processing of CGI arguments under TCL
    - More information on CGI.

    - if you need a searchable index, this is supposed to do the trick. I haven't messed with it yet, though.

    NASA's 'Information on Search Tools'
    - a interesting page with many ideas on solving local searching problems.

    - A great language to learn in the generation of dynamic documents (on-the-fly page creation) such as forms.

[ Home ]   [ About ]   [ Plans ]   [ Designs ]   [ Graphics ]   [ Marketing ]   [ Hosting ]   [ Portfolio ]   [ Contact ]   [ Site Map ]
Copyright © 1995-2000 XyNexT Internet Strategies - All Rights Reserved Worldwide