HubNut Technical Support



Using CGI-Scripts

The personal cgi directory feature allows you to run any cgi script from a directory located inside your home directory, provided the script confirms to the terms and conditions of our usage agreement.

The 'cgi-bin' directory allows you to execute a CGI script written in PERL, UNIX or C shell.  PERL and shell programs are self-compiling and can be utilized immediately after transfer.

Uploading Scripts

To upload a script, login to your virtual server using FTP.  Once logged in go to the directory where you want to upload your cgi script to, this is usually /web/cgi-bin.  Make sure that your FTP client is set to ASCII mode (if you upload in binary mode then your script will not work), upload your cgi script ensuring that it has a .cgi or .pl extension.

Setting File Permissions

To make a script work then you must make the script executable, you do this by setting the permissions on the script.  A cgi script should be given the following permissions:-

chmod 700 or owner=read/write/execute, group=nothing, world=nothing

Setting Paths and Variables

Variables and paths are the parts of the script that you must configure so that the script knows where data and programs can be found. Absolute and URLs will most likely be used in cgi scripts and if so you need to know where they are.

The main paths are as follows:

  • PERL - /usr/bin/perl

  • PERL 5 - /usr/bin/perl

  • Sendmail - /usr/sbin/sendmail

  • Date Program - /bin/date

  • Web directory - /home/sites/www.<your-domain>/web

  • CGI-BIN directory /home/sites/www.<you-domain>/web/cgi-bin

The first line of all PERL scripts must therefore be :

#!usr/bin/perl

An absolute path is a path to a certain file or directory on the server.  For example you might want to set a variable ($links) to the absolute path to your links.pl file.  When configured properly the link should look like:

$links="/home/sites/www.<your-domain>/web/cgi-bin/links.pl";

The script may also ask for the URL to this file (links.pl). If the variable were $links then set it as follows:

$linksurl="http://www.<your-domain>/cgi-bin/links.pl"

Scripts obtained from free archives will almost always require the variables to be defined as we have done above.  This is the most common source of problems with scripts not working properly so make sure your variables are set correctly.

Testing Scripts

SSH Telnet is useful to test your cgi scripts.  To test your script you must execute it on the server which means your permissions must allow the user to execute the script, otherwise a permission denied error will occur.

Go into the directory where the script you wish to test resides, say test.cgi in your cgi-bin directory.  Therefore 

cd /home/sites/www.<your-domain>/web/cgi-bin

To execute the cgi script type ./test.cgi  The server will then execute the script and tell you what if any problems occur.  After you have found any problems you can edit your script using PICO or Vi in Telnet, then test it again.  Eventually you will get your script working and then can test the script from your browser.

Useful Links

The best place to find free cgi-scripts and to lean more about PERL are at www.cgi-resources.com, www.perl.org and www.perl.com. We also recommend Matts' Script Archive.  Unfortunately, HubNut cannot provide support for scripts that do not work, instead you should contact the author of the script for support.



 Email : support@hubnut.net 

 

© 1999-2004, HubNut Limited - Registered in England and Wales no. 3932100