Using Your Own CGI Scripts

You can create and execute your own CGI scripts with any LiveZone Web site package running a virtual Web server.

Currently, LiveZone Starter and LiveZone Basic packages don't include a virtual server. These packages are able to run standard CGI scripts we've built-in to our servers; for more information see the description of our Built-In CGI Scripts.

CGI scripts can be written using Perl or C languages, or any of the standard Unix shell scripts. You can write your own scripts, or obtain other share-ware or commercial scripts. Whatever the source, you install and execute the scripts the same way.

The CGI Server Environment

When your scripts execute, they are capable of doing anything to your Web site that you could during an FTP session. So, be careful of the scripts you run. Debug them, test them, then use them carefully. (Technically, the execution environment is said to be setuid to your FTP login username, chroot to the same directory structure as you encounter when using FTP to access your Web site, then cd /cgi-bin.)

Although your scripts are capable of doing evil things to your own Web site, they have no access to any other part of the server. Your Web site is protected against reading or writing by any other LiveZone client's scripts, no matter how ill-behaved.

Install Your Script

Upload your script to the LiveZone server using FTP to the /cgi-bin directory of your Web site. Your scripts must be in this directory to be used as CGI scripts. This special directory helps ensure that Web users other than yourself won't be able to get-at your scripts except to run them as part of your HTML pages.

Prepare the Script for Execution

Unix distinguishes between files that are ordinary HTML data files, and those that are program files. Scripts are just one type of program file. Normally all files are treated as HTML files. To prepare your script for use, you must first tell the server that the script is a program file.

You could do this with the Unix command (assuming your script is called "format.pl"):

chmod +x format.pl

For security reasons, we won't let you access the LiveZone servers directly. Instead, you'll find a menu item in yout FTP program (such as Fetch or CuteFTP) with a name such as "FTP Site Command" or "Remote FTP Command". This menu item is used to send Unix commands to the FTP server to manipulate the files you've placed there. You should send the command (assuming your script is called "format.pl"):

SITE CHMOD 755 /cgi-bin/format.pl

The importance of the 755 is best understood from a Unix manual describing the chmod command. If you use 644 instead of 755, the execution attribute will be removed. As a simple reminder for those "in the know", owner, group, others; 4=read, 2=write, 1=execute.

Using Your Script

Edit your HTML file to access your script. Although your scripts must be in your Web site's /cgi-bin directory, you actually reference your scripts using a "CGI Wrapper" that requires a slightly more elaborate syntax. An example of this follows (assuming your script is called "format.pl"):

<FORM METHOD=GET ACTION="/cgi-bin/mycgi/format.pl">

The complete/cgi-bin/mycgi specifier is required for all your scripts. If you forget the /mycgi specifier, the server will look in the server's built-in /cgi-bin directory (instead of your directory), and your script won't be found.

In special cases, CGI scripts won't want the Web server to parse the script results. These are known as "NPH" scripts. NPH scripts are apparent because the first four letters of their name are "nph-". The previous example is modified below to illustrate using an NPH script. Note that the script file is actually named nph-format.pl as well, not just format.pl.

<FORM METHOD=GET ACTION="/cgi-bin/nph-mycgi/nph-format.pl">

Debugging Your Script

Normally when a script executes, the results are immediately parsed and displayed by your Web browser before you can inspect the script's output.

To assist debugging, there are two additional directory specifiers: /mycgid and /nph-mycgid; these cause the script output to be displayed by your browser as text, instead of being interpreted as HTML directives. Below are two examples of debugging script output:

<FORM METHOD=GET ACTION="/cgi-bin/mycgid/format.pl">
<FORM METHOD=GET ACTION="/cgi-bin/nph-mycgid/nph-format.pl">



www.livezone.com
   

To SupportZone Main Page

Last Updated January 2007
Copyright (c) 1995-2007 by LiveZone Communications LLC. All rights reserved.
WomenZone, BusinessZone, SupportZone are trademarks of LiveZone Communications, LLC.
LiveZone is a registered trademark of LiveZone Communications, LLC.