Configuring and installing a perl script on the server


[ Zettels Traum ] [ search / suche ]


Configuring and installing the script on the server
The perl script is an ASCII text file and can be edited with any simple text editor. 
But watch out for this: UNIX, MacOs and DOS descendants each have different standards 
for the end-of-line char. If i.e. UNIX chokes on dos CRLF you get a server error 500.

For uploading and attrib setting of the perl script and related files you'll need 
an FTP client. On the mac, Fetch version 3 allows for file attrib setting and is 
recommended. Fetch is available at many Mac ftp sites including:

Internet Software For The Macintosh 


On Windows WS_FTP32.exe or CuteFTP do fine.

Default values and how to change them

First line of the perl script pointing to the perl interpreter
This path is pretty much standard on unix servers:

#!/usr/bin/perl

(in this, /usr/bin/perl is the path while #! is an instruction, another server 
might have the path to the perl interpreter set to /bin/perl, in this case the 
first line of the perl should read like this:
#!/bin/perl
On NT servers this is not important as long as the perl interpreter is included 
in the path= statement of the autoexec.bat)

Uploading 

Usually an ISP will have some info available on server specific requirements 
to cgi programms, i.e. a dedicated page in his member area. 

Usually it is required to copy executabale files in a certain directory (cgi-bin) 
sometimes they have to have certain file extensions. At least on UNIX servers it 
is important to set the file attributes of the cgi file.


Uploading via FETCH:

1.Open Fetch by double-clicking on the Fetch icon. 
2.Open Connection: 
a.Enter host: your servers url here
b.Enter userid: loginname 
c.Enter password: your password 
d.dir: leave blank and it will default to your home directory. 
Change to your cgi-bin directory from there.

3.Click the "Put File..." button. If you want to load multiple files at a time, 
  instead of clicking on the "Put File..." button, select "Put Folders and Files" 
  from the Remote menu. Open the directory on your Mac that contains the
  files you want to move to the server. 
4.Double click on the file you want to move. 
5.Save file with the file name you want to use on the server. 
6.Choose the correct format for your file: For text files (or .pl files) 
  select "text" in the dialogue box then click Okay. For graphic files 
  (.gif or .jpg) select "raw data" in the dialogue box then click Okay. 
7.Quit Fetch by selecting QUIT from the File menu. 

To make a perl script executable you will have to:
- obtain information from your ISP about some details that servers software is setup. 
  Some server require certain fileextensions for executable cgi files, i.e. *.cgi 
  or *.pl, some support both or more, some server setups don't ask for any special 
  extension.

- Set the file permissions accordingly. The recommended permissions for a cgi 
  script are rwxr-xr-x (chmod 755). See below in the appendix for more information. 
  To set the permissions with Fetch:

   1.Choose the file.cgi 
   2.Choose the REMOTE|SET PERMISSIONS 
   3.Choose the appropriate permissions 


- Get to know the path to the perl interpreter in the servers file system. The 
  first line of the perl script should point to that path. See below for further 
  information.


Creating a database directory and uploading the database files

Open the line to the net, open Fetch and log to your home directory, change to 
the cgi-bin directory. Choose "Create New Directory" from the menu bar. 
Name the new directory "database" (Uppercase/lowercase counts, this is true for
all filenames and path names on UNIX. The values in the editable section of the 
perl script and the names in the directory have to be identical)

Now change into the new directory. Upload the database files by using the Put 
File command of the Fetch program.


Setting permissions

Files that the cgi will write to must have appropriate file attributes. 
Select the file in the file window of Fetch. Now choose from the Remote Option 
in the menu bar the command Set permissions.

You'll see a table with columns for Read/Write/Executable  and rows 
owner/group/everyone.
The cgi has no special rights, it will count as everyone. 
Choose aFile.txt and in the permissions table check all three boxes in the Read 
column and all three boxes in the Write column.

Another way of doing the same is to choose Remot|Send FTP Commands and type the 
line

Site chmod 666 aFile.txt

into the dialog. 


Uploading the cgi

Open the line to the net, open Fetch and log to your home directory, change to the 
cgi-bin directory. Upload the perl files by using the Put File command of the Fetch 
program. 
IMPORTANT: you must upload the perl script file as text, otherwise it won't 
function at all. Fetch has several options, default is Auto. Do not trust that 
Auto option but choose Text.

Setting permissions

Files that will be executable on a UNIX server must have appropriate file attributes. 
Select the file in the file window of Fetch. Now choose from the Remote Option in 
the menu bar the command Set permissions.

You'll see a table with columns for Read/Write/Executable  and rows 
owner/group/everyone.
The cgi has no special rights, it will count as everyone. 
Choose some.pl (or what other name you choose to name it) and in the 
permissions table check all three boxes in the Owner row, check the Read and 
Executable box in the Group row and check the Read and Executable box in the 
Everyone row.

Another way of doing the same is to choose Remote|Send FTP Commands and 
type the line

Site chmod 755 some.pl

into the dialog. 

Permissions

There are three levels of access to any file: user, group, and world. 
Each access level has three permissions:
read, write and execute. The file permission code is made up of 9 characters: 
read, write and execute (in that order) for user, group and world (in that order). 
A file that is readable, writable and executable by the user, readable and 
executable by the group and readable only by the world would look like this:

rwxr-xr-- user owner group owner filename 



























D. Plänitz