Smart.Net's CGI Script User Reference (Using PERL)


CGI (Common Gateway Interface) scripts in your WWW page require two elements: the CGI script, and the HTML file from which the CGI script was called.

The CGI scripts for SmartNet may be written in either Perl, an interpreted scripting language, or C, a compiled (binary) language (which we will not be discussing in this page).

A Perl CGI script must be an ASCII text file with no line feed character. (MS-DOS ASCII text files have a carriage return character and a line feed character at the end of each line. To convert a MS-DOS ASCII text files to a ASCII text file with no line feed character, use the pico editor in the Unix shell. Pico automatically strips out the line feed character when saving an edited MS-DOS ASCII text file.)

Your Perl script must specify the location of the Perl interpreter. To specify the location of the Perl interpreter the following statement must be at the beginning of your script.

#!/usr/bin/perl

Your HTML files should contain a <FORM> tag. This <FORM> tag calls on a CGI-script or program and should look something like this (if you are using a public script from SmartNet's archive):

<FORM METHOD=POST ACTION="/cgi-bin/script.cgi">

For instance, to use our public guestbook, the FORM tag would look like this:

<FORM METHOD=POST ACTION="/cgi-bin/gb-generic.cgi">

If you want to create your own CGI scripts, you can use your personal CGI-BIN directory. If you do not have a cgi-bin directory, you can create it using these steps:

The <FORM> tag for your personal scripts would look like this:

<FORM METHOD=POST ACTION="/yourname-cgi-bin/script.cgi">

For instance, if your username was kevinr, you would call your scripts like this:

<FORM METHOD=POST ACTION="/kevinr-cgi-bin/script.cgi">


Technical Support: support@smart.net
Billing: billing@smart.net
Webmaster: webmaster@smart.net