E-Mail has been successfully sent.

How to start a Perl script

This article covers the following topics around Perl scripts.

Table of contents Table of contents

When is a Perl script startable?

The first line in a Perl script shows the interpreter and could look like this:

#!/usr/local/bin/perl


This line has to be adjusted to the STRATO-System as follows:

#!/usr/bin/perl

Now the attributes for this file (script) have to be adjusted.

UserGroupOthers
ReadReadRead
Write--
ExecuteExecuteExecute

This corresponds to Unix-CHMOD 755.

Note: Perl is available from the Hosting Starter (older package types from BasicWeb XL, PowerWeb Starter). Furthermore, the Perl script is also only startable if it is in the cgi-bin folder.

 
 

How can I check whether my Perl script is interpreted correctly?

With SSH you can find out whether Perl scripts you use are interpreted correctly by the server. SSH is available from the STRATO Hosting Plus package. To do this, call up an SSH client (for example the tool PuTTY).

If you need detailed information on how to use SSH access, please read the following article first:

How to use SSH/SFTP

Once you have downloaded PuTTY, please start the programme. Enter ssh.strato.de (or ssh.strato.com) as the host name.

PuTTY SSH

Now the command line opens. Please enter your user name (domain) and your password (master password) here.

Then enter the command perl and CTRL+D.

Wann ist ein Perl-Script startf�hig?-2.png

("www.wunschname.de" means the same as "www.desiredname.com")

The Perl versions currently interpreted by the server are displayed. In the next step, check whether the syntax of the script you are using can be interpreted correctly.

Call up the directory in which the script to be checked is located.

Enter the following command:

perl[highest version number] -c scriptname.pl

In our example, the directory is cgi-bin and the name of the script is test.pl. Please replace "perl[highest version number]" with the version number shown - in this example, perl58pl.


Wann ist ein Perl-Script startf�hig?-3.png

The result of the check (OK) is displayed directly.

 

How can I access the database via Perl?

From STRATO Hosting Starter onwards (older packages: from BasicWeb XL, PowerWeb Starter) you have the option of using MySQL databases for your Internet presence.

This is how you can use our MySQL database

For a connection via DBI module in Perl, you also need the following parameters:
•   Host: rdbms.strato.de
•   Username: [Username] (U####### oder dbu#######)
•   Database: [Databasename] (DB####### oder dbs#######)

A connect in Perl could look like this:
(the entries DBXXXX, Uxxxx, as well as the password are to be replaced by your own entries)


#!/usr/bin/perl

use DBI;
use CGI;

$dbserver="DBI:mysql:DBXXXX:rdbms.strato.de";

$dbuser="Uxxxx";
$dbpass="XXXXXX";
$sqlcommand="select * from NameOfTable where Field=Value";
$dbh = DBI->connect($dbserver,$dbuser,$dbpass); #Login at database
$sth = $dbh->prepare($sqlcommand); #prepare SQL-Command
$ok=$sth->execute; #send SQL-Command
...... and the rest of the script!

When entering the database name, please ensure that the letters "DB" and "U" are capitalised. A connect via e.g. "dbxxxx" will fail.

Was this article helpful?
Info: 99b9c9928d03bce1dca01ae78ddea0d5cc7a8766