Veren Services is for any person who is searching

  INTRODUCTION:

HOME

ABOUT

TECH ARTICLES

EDUCATIONAL

CONTACT

SERVICES:

DESIGN

HOSTING

CLIENTS

SHOPPING CART

MARKETING

NETWORK:

CAPITAL CELTIC

HEALY CLAN
ORGANIZATION

ED HEALY
ONLINE

 
 
 
     
 



Common Gateway Interface (CGI)

CGI or Common Gateway Interface, allows programs and scripts to run on the web server and be parsed to a web page. CGI files can be used to add functionality to your website. Examples of this are processing forms, searches and counters. CGI programs can be written in a number of languages, including C, C++, PERL.

Running CGI on a Virtual Server
Hosting clients with cgi access already have a directory to store your programs. This directory is called cgi-bin. The path to perl on our servers is:

/cgi-bin/perl

Responsible CGI
Virtual servers give you immense freedom in executing CGI programs at no cost. Many providers limit their users access to CGI. We do not. We would suggest that you do not use scripts that put undue stress on CPU resources, as this will slow down your server, and thus the speed at which your visitors can access your site.

Most virtual servers will NOT debug CGI programs
We are responsible for the operation of the system. We are not responsible for programming or debugging. Please do not contact support with matters concerning CGI programs. CGI requires at least a working knowledge of programming and the UNIX system. If you would like to learn more about CGI, the following links are good starting points.

CGI Links
Here is a small collection of links about CGI.

  • Boutell Web Tools

  • CGI-Resources

  • Matt's Script Archive

  • NCSA site on CGI


    Common Gateway Interface (CGI)

    Troubleshooting
    The most common problems you will encounter with CGI programs are most likely to be the simplest.

    We recommend you review the following checklist if you are having problems.

    • CGI scripts must have the extension .cgi or .pl (if it is a PERL script).
    • Scripts have to be placed in a directory off your public_html dir; named cgi-bin.
    • CGI scripts must be made executable. You will use the command: chmod 755 file.cgi
    • Files that will be written to by a cgi script need to be world-writeable: chmod 766 file.html
    • Directories that will be written to by a cgi script also need to be world-writeable:
      chmod 777 dirname
    • Try to execute the script at the unix prompt. If there are formatting problems, you will see error messages that aren't displayed when a script is executed from the web.
    • If the script executes from the unix prompt, but not from the web, recheck your permissions.

    Finding Bugs
    One method of finding bugs is to put lines like these in your perl code to try to find the point where the script fails:

    print "Content-type: text/html\n\n";
    print "<h1>Got Here!</h1>";
    exit;

    If you see "Got Here!" when you run the script from the Web, you know the script is OK up until that point. Now move these lines further down to the next point where there might be a problem.


    Server Side Includes (SSIs)

    A server side include, or SSI, is a piece of code that is embedded into an HTML page and interpreted by the the server before the page is sent to the client's browser. SSIs allow you to include information in your HTML files like a file's date of last modification, or even another HTML file.

    Server Side Includes are server intensive. Because all files need to be parsed by the server, having all of your pages SSI would cut performance.

    We request that you respect this aspect when using SSI's. For example, it does not make sense to have all of your files use SSI just to add a "last modified date" to them. It is just as easy and faster to change the date manually when you modify the file. Please keep this in mind when using SSI. Your pages will load slower, so use them sparingly.

    Any file that has the extension .shtml will automatically be parsed by the server. You can use index.shtml instead of index.html as your default directory file.


    SSI Commands

    Syntax
    A server side include command is contained within a comment tag, for example:

    <!--#command argument="value" -->

    NOTE - Syntax must be correct, or your include will not work.


    Commands
    There are six (6) available commands. Click on each to see an example.

    Include

    Include allows you to have another file included, or embedded, into the shtml file. It cannot include the output of a CGI script.

    Echo

    Echo can be used to include the contents of an environment variable, like the current date.

    Exec

    "Exec" will execute a Unix command or CGI
    script.

    Fsize

    "Fsize" returns the size of a specified
    file.

    Flastmod

    "Flastmod" returns the last modification date of a specified
    file.

    Config

    The "Config" command is used to control things like the format of output and error messages generated by parsing process.

     

    Include
    Used to include the contents of another file in a shtml file. The include command has two possible arguments: virtual and file.

    "Virtual"
    Used when the path to the document is given relative to the document root (usually your public_html directory.)

    "File"
    Used when the path to the document is given relative to the shtml file itself.

    NOTE - You cannot use "file" to go up a directory ("../file.html" won't work.)

    Examples
    Say you want to include the file named "file.html" which resides in the same subdirectory as this shtml file.

    To include it using "virtual," you would use:

    <!--#include virtual="/full/path/to/the/file.html" -->

    To include it using "file," you would use:

    <!--#include file="file.html" -->

     

    Echo
    The echo command includes, or "echoes," the contents of an environment variable.

    Here are some examples showing the SSI tag and the results:

    <!--#echo var="DOCUMENT_NAME" -->
    This document is named: fssi.shtml

    <!--#echo var="DATE_LOCAL" -->
    You accessed this document: Tuesday, 03-Jun-97 14:02:35 EDT

    <!--#echo var="DATE_GMT" -->
    This is the same as the above, but in Greenwich Mean Time: Tuesday, 03-Jun-97 18:02:35 EST

    <!--#echo var="DOCUMENT_URI" -->
    The URI (the path form document root) of this document is: /~vmirror/ssi/fssi.shtml

    <!--#echo var="LAST_MODIFIED" -->
    This document was last modified: Friday, 01-Nov-96 15:22:57 EST

    <!--#echo var="HTTP_REFERER" -->
    The user came by way of a link from: http://www.digiweb.com/support/tutorial.shtml

    <!--#echo var="HTTP_USER_AGENT" -->
    The browser used to access this document was: Mozilla/4.0b3 [en] (WinNT; I)

    Echo Command Values List The following list provides you with all the available values to use with the Echo command.

     

    Echo Commands
    The following list provides you with all the available values to use with the Echo command.

    SERVER_SOFTWARE server application
    SERVER_NAME hostname of the server
    SERVER_PROTOCOL server protocol
    SERVER_PORT listening TCP port
    REQUEST_METHOD HTTP method used by the client
    REMOTE_HOST domain name of the client, note DNS option must be set
    REMOTE_ADDR IP address of the client
    AUTH_TYPE method that the client used for authorization
    REMOTE_USER username entered by the remote client
    CONTENT_TYPE MIME type of the content posted by the client
    CONTENT_LENGTH size of the data posted by the client
    DOCUMENT_NAME name of the document requested
    DOCUMENT_URI URL of the document requested
    DATE_LOCAL current date, format specified by the config command
    DATE_GMT The current GMT, format specified by the config command
    LAST_MODIFIED document modified date, format specified by the config command
    PAGE_COUNT number of hits on the current document since server came on-line
    TOTAL_HITS number of documents server has served since coming on-line
    REFERRER The URL of the document the viewer came from

     

    Exec
    The exec command can execute either a Unix command or a CGI script

    UNIX Command
    To execute a UNIX command you must use the argument "cmd", for example:

    <!--#exec cmd="/usr/bin/date" --> This executes the Unix date command.

    CGI Program
    To execute a CGI program you must use the argument "cgi", for example:

    <!--#exec cgi="./hello.cgi" --> This executes the CGI script, hello.cgi.

    NOTE - All the environment variables passed to the CGI script are the same as those for the shtml file itself.

    Query String
    You cannot pass a query string using a question mark (?), as in:

    <!--#exec cmd="hello.cgi?query" --> This will result in an error.

    NOTE - The query string passed to the CGI script will be the same as the query string passed to the shtml file itself. If this file were refernced as "ssi.shtml?snort", then the word "snort" would also be passed to the "hello.cgi" script above.

     

    Fsize
    The fsize command returns the size of the specified file in bytes. It uses the argument "virtual," which is the path to the file is given relative to the document root (usually your public_html directory).

    To find the size of picture.gif, you would use:

    <!--#fsize virtual="graphics/picture.gif" --> - This would return then return the file size.

    You are probably now asking, what can I use this for? Example: You offer some files available for download on your site and would like to give people an idea of how big the files are.


    Flastmod
    The flastmod command returns the date the specified file was last modified. The flastmod command uses the argument "virtual," which is the path to the file is given relative to the document root (usually your public_html directory).

    To find the last modified date of a file, you would use:

    <!--#flastmod virtual="filename.txt" --> This would return: Wednesday, 31-Jan-97 11:59:59 EDT

     

    Config
    The config command is used to control how the results of other SSI are displayed. There are three possible arguments: timefmt, sizefmt and errmesg.

    To set the format for the date to dd/mm/yy, you will use:

    <!--#config timefmt="%d/%m/%y" --> The date will now be displayed as: 03/06/97

    The field descriptors used by this SSI tag are the same as those used by the Unix date command.

    Notice the dates displayed above this config command use the normal date format. The one below it uses the new format.

    To set the format for how file sizes are displayed, you use:

    <!--#config sizefmt="abbrev" --> or <!--#config sizefmt="bytes" -->

    Depending on whether you want the size given in total bytes or abbreviated as "1k".

    To set error message returned when an SSI tag fails, use:

    <!--#config errmsg="Error" --> A failed SSI tag will now return: Error

     

    Field Descriptors
    When used with the date command, it must be preceded by a "%"

    a abbreviated weekday name
    A full weekday name
    b abbreviated month name
    B full month name
    c locale's appropriate date and time representation
    C default date and time format
    d day of month - 01 to 31
    D date as %m/%d/%y
    e day of month - 1 to 31 (single digits are preceded by a blank)
    h abbreviated month name (alias for %b)
    H hour - 00 to 23
    I hour - 01 to 12
    j day of year - 001 to 366
    m month of year - 01 to 12
    M minute - 00 to 59
    n insert a new-line character
    p string containing ante-meridiem or post-meridiem indicator (AM or PM)
    r time as %I:%M:%S %p
    R time as %H:%M
    S second - 00 to 61, allows for leap seconds
    t insert a tab character
    T time as %H:%M:%S
    U week number of year (Sunday as the first day of the week) - 00 to 53
    w day of week - Sunday = 0
    W week number of year (Monday as the first day of the week) - 00 to 53
    x Country-specific date format
    X Country-specific time format
    y year within century - 00 to 99
    Y year as ccyy (4 digits)
    Z time zone name

     



  •  
         
       

      HOME     CONTACT