Perl

All our Linux servers does have the ability to run CGI scripts written in Perl.

Custom CGI Scripts

To use a CGI script please upload them to your account via FTP. Scripts can be placed in any folder you wish, although a default ‘cgi-bin’ folder is automatically created for your convenience. Scripts must have an extension of .cgi or .pl. Ensure that your FTP program uploads the file in ASCII mode and be sure that you set the correct file permissions using the ‘chmod’ command from within your FTP client.

Key Information

You might like to make use of the following parameters if required when configuring CGI scripts to run on our servers. If you require more information regarding the configuration of our servers please contact us.

Path To Perl /usr/bin/perl
Perl Version 5.8.8
Path To Your Webspace /home/username/public_html

Debugging CGI Scripts

‘500 Internal Server Error’ pages usually indicate an error or misconfiguration when you try to run a CGI script. Your Error Log page may help you to solve the problem.

Example

Here’s a basic CGI script that shows how to connect to a MySQL database on our platform, and execute a simple query:

#!/usr/bin/perl -w

use strict;
use DBI;
print “Content-type: text/html\r\n\r\n”;
my $dbh = DBI->connect(“DBI:mysqlatabase=username;host=mysql.interdns.co.uk;port=3306”, “username”, “password”);
my $sel = $dbh->prepare(“SELECT VERSION()”);
$sel->execute();
my $ver = $dbh->fetchrow_array();
print “server version: ” . $ver;
$dbh->disconnect();