| ||||
General CGI Script Procedure | Guestbook Procedure
This page presents the procedure for adding a Guestbook script to your Web site. For installing other CGI scripts, refer to the General CGI procedure.
Download the guest book script: Go to Matt's Script Archive http://www.worldwidemart.com/scripts/. Go to the Guestbook section.
Download the zipped (.zip) file for Windows / Macintosh.
Unzip the file. You may need a program such as WinZip, PkZip or Stuffit Expander to open it.
It contains the following files:
The .html and .htm files are Web pages. The .pl files and .cgi files are the CGI script files. The README file is a text document containing directions.
NOTE: You may not always see the filename suffix or extention such as ".pl" or ".html" when looking at the files in Windows. To tell Windows to show the suffixes, do the following:
|
Read over all the documentation for the script in the README file. This tells you where you will have to upload the files and what changes you will have to make in the code of the script. In the case of this guestbook script, we have spelled out all the changes you will need to make to install it on Penn State's Personal Web server. Reading and understanding the documentation is really the most important step to installing a script.
Open the guestbook.pl file. You will need to open the file in a text editor. See the table below for examples. We recommend WordPad for Windows users, TextEdit for Mac OS X and BBEdit (if available) for Mac Classic.
The location of the Perl interpreter program on the Penn State Personal, Clubs and Departmental servers is /usr/local/bin/perl. This means the first line of every Perl script .pl and .cgi file should be:
|
When you save the guestbook.pl file, make sure you save it as a Text Document (.txt) format or plain text file, not Rich Text Format (.rtf) or Unicode.
If there is a setting for the Encoding, make sure it is set to ANSI, US ASCII or Western, not Unicode or UTF-8. Make sure the filename doesn't change as some programs may want to rename the file to end in .txt rather than .pl.Finally, the script will need to be saved in Unix line ending format. Unix, Windows and Macintosh each use different byte values to indicate the end of a line in a text file. Many text editors do not know how to save in Unix line ending format, so the files will need to be converted during upload to the servers. After saving a file in the regular format for your system, you can convert a text file to Unix format during upload by using SSH Secure File Transfer or MacSFTP in a special mode called "ASCII" or "Text". See how below under "To convert .cgi and .pl files to Unix format."
| Text editors you can use and how they handle Unix line ending format | |||
|---|---|---|---|
| If you use | You can use | Open Unix formatted files | Save Text Document (.txt) files in Unix format |
| Windows (95 or newer) | Notepad | No (*) | No (**) |
| Wordpad | Yes | No (**) | |
| DOS Edit | Yes | No (**) | |
| Macintosh Classic (8.x and 9.x) | SimpleText | No (*) | No (**) |
| BBEdit | Yes | Yes | |
| Macintosh OS X | TextEdit | Yes | Yes |
| WorldText | Yes | Yes | |
| BBEdit | Yes | Yes | |
| Unix (or Linux) | vi | Yes | Yes |
| emacs | Yes | Yes | |
| pico | Yes | Yes | |
| * - If you try to open a Unix formatted file with this editor, the text will look jumbled with block symbols. | |||
| ** - You will need to convert the file to Unix format before using as a CGI script (.pl or .cgi file). | |||
Make the following changes to the guestbook.pl file. Use your own Penn State Access Account userid in place of the example userid, xyz123.
| This line: | should be changed to read: |
|---|---|
Open the guestbook.html and addguest.html files. You can use the same text editor as you used to edit the guestbook.pl file. You can also use an HTML editor such as Dreamweaver, but these directions are for a text editor. Make the following changes, followed by any other recommended changes in the README file. Please use your own Penn State Access Account userid in place of the example userid, xyz123.
| In this file: | change this line: | to read: |
|---|---|---|
| addguest.html | ||
| guestbook.html | ||
| guestbook.html |
Using the file transfer method of your choice, log in to your Web space.
For instructions on transferring these files to your Web space, see question 2.4 of our Web Frequently Asked Questions.
Make sure you are within your "www" folder.
Make a new folder.
Name this folder "scripts" (You can name this folder anything you like, in this example we are calling it "scripts").
Double click on the scripts folder to move into that folder (in the PASS Explorer on the Penn State Portal, select the scripts folder and click the "Change To Selected Folder" button).
Transfer your edited files to this scripts folder.
To convert .cgi and .pl files to Unix format during upload, do the following: |
To set permissions correctly, you will need to:
|
For security reasons, the Personal Web server is configured in such a way that a typical user cannot make changes to the files in your www folder. For CGI scripts to make changes, the Web server program must be given write permission to the data files. The Web server program on http://test.scripts.psu.edu/ runs with the identity of a "user" called test.scripts.psu.edu, and is in the group called test.scripts.psu.edu. You should give the group test.scripts.psu.edu write permission to files your CGI program needs to change. You should not give write access to everyone to limit the possibility of someone accidentally or maliciously changing or deleting your CGI data. The Secure Server (at https://www.work.psu.edu/ on the Web) provides a way to set permissions for test.scripts.psu.edu, so that the script can run and save changes your visitors make when they use your script. For reading or executing files, it is sufficient to give the Web server program access by giving everyone Read and eXecute permissions (see below). The "user" test.scripts.psu.edu is also in the group called access, which is the group all Penn State Access Accounts are in. |
To set the guestbook.pl file with execute permission:
To set the guestbook.html and guestlog.html files with write permission:
Test out your form.
If you encounter any problems, you should consult the troubleshooting section of the general CGI procedure for advice. If you still have trouble, contact webmaster@psu.edu.