About usContact usSite help
Quick links
Search this site

Developing your website FAQ

Which mode do I upload my scripts as, ASCII or binary?
What scripts can I run in my cgi-bin?
Which versions of Perl do you support?
What should the first line of my script be?
What do I need to get my scripts to run?
What do I need in my scripts to print HTML?
Is there any way I can test my scripts on the server?
How do I get the date command to work in my script?
How do I send email from my script?
How do I reference a file in the docs directory from my script?
What does Post Method Not Implemented mean?
What can I do about getting server errors?
How do I control robots and web spiders?

UNIX format (uploading scripts)

Any CGI script that you intend to run on the server must be in Unix format. Although you may be unable to save the file on your own local machine in Unix format; if you upload the file as ASCII, it will be converted to the relevant format.

On a PC based platform, you would upload the file as ASCII, and on a Mac based platform you would use Plain Text.

Running scripts on the server

We only allow Perl scripts to run from the cgi-bin directory. We currently support Perl 4 and Perl 5.004.

If you wish to use Perl 4, then the first line of your CGI script should be:

#!/bin/perl

and if you wish to use Perl 5, then you should add a 5 to the end of the line, so that it becomes:

#!/bin/perl5

Blank lines in scripts

The first line of a Perl script must start with '#!/bin/perl' this must be the first line of the script, and there should be _no_ blank lines above this. This is quite a common problem to introduce when cutting and pasting forms from your Browser.

cgi Permissions

Once you have uploaded your cgi scripts to the cgi-bin using FTP, you will need to telnet into your web account and set the permissions to executable for your script to work. More details on this can be found in the Developing Your Site Further section, under Using cgi-bins.

Content type definition

For the server to know what type of document it is to serve, you need to define a Content-type. This would normally be text/html, though you could choose something else if you wished. You MUST define this Content-type before outputting any information to your browser using print or similar.

Before your script can display HTML in the users browser, you will need to define the HTML content type definition. This is done by adding the line:

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

to your script before you print any HTML.

Testing your scripts

There is no way of testing your scripts by running them on the server, other than via your web browser. However, there is a debug facility available, details of which can be found under Using cgis in the Developing Your Site Further section.

Obtaining the date within Perl

To obtain the time and date from the server, we recommend that you use the gmtime() function with Perl, which returns a 9 bit element. When used in a scalar context it returns something similar to date.

Referencing sendmail

The Mail Transport Agent (MTA) on the server that you are able to use is called sendmail, and you are able to reference this in the following manner:

/usr/lib/sendmail

How to refer to other files

To refer to files from your scripts that are in your docs directory you should use the following path:

/docs/www.yourdomain.co.uk/yourfile

Error messages

There are two error messages you may see:

Post method not implemented

This means that you are probably calling the script incorrectly from the HTML.

The other message you may see is a server error. This is usually when there is a syntax error in your script. Things to check:

That you have no blank lines at the top of your script
That you have a content definition
That you have a uploaded the file in UNIX format.

If necessary, you should also try debugging your script.

Robots and robots.txt

Robots, also called Web spiders or crawlers, are programs which automatically retrieve documents and all the documents listed within each document, recursively. These robots are used to create listings of Web pages available, for example directories accessible by search engines. Normal Web browsers are not robots, as they are operated by a person, as opposed to automatically retrieving referenced documents More information about robots in general can be found on http://www.robotstxt.org/wc/faq.html.

Robots will access a file called /robots.txt first to look for instructions about the site. Web-forwarding customers may see error messages in their access logs from attempts to access this file. To stop these error messages, you can simply include an empty file called robots.txt in your top-level directory. Information about how to generate a robots.txt file, which enables web-forwarding customers to control accesses to their site by robots, is available on http://www.robotstxt.org/wc/exclusion.html. However this will not protect your directories from robots.





*