Making Your Web Page Interactive with CGI

22
Making Your Web Page Interactive with CGI TLN Technology Committee February 16, 1999

description

Making Your Web Page Interactive with CGI. TLN Technology Committee February 16, 1999. What is CGI?. “A method used by www pages to communicate with programs run on the web server.” Glossary of Internet Terms. Finding Scripts. Matt’s Script Archive worldwidemart.com/scripts - PowerPoint PPT Presentation

Transcript of Making Your Web Page Interactive with CGI

Page 1: Making Your Web Page Interactive with CGI

Making Your Web Page Interactive with

CGI

TLN Technology CommitteeFebruary 16, 1999

Page 2: Making Your Web Page Interactive with CGI

What is CGI?

“A method used by www pages to communicate with programs run on the web server.”

Glossary of Internet Terms

Page 3: Making Your Web Page Interactive with CGI

Finding Scripts Matt’s Script Archive

worldwidemart.com/scripts

CGI Resource Index www.cgi-resources.com

Web Scripts awsd.com/scripts/

Page 4: Making Your Web Page Interactive with CGI

Downloading Once you’ve found the script you

want, download it and all the associated readme and html files.

Be sure to download in ascii text mode. If available, save individual files instead of

.zip file. This is the easiest way to ensure that the files are saved in ascii format.

If you must use the .zip file, open files in word after unzipping them to save them in ascii format.

Page 5: Making Your Web Page Interactive with CGI
Page 6: Making Your Web Page Interactive with CGI

Recognizing Ascii Format

Page 7: Making Your Web Page Interactive with CGI

Customizing Scripts

Page 8: Making Your Web Page Interactive with CGI

Customizing Scripts

The first line of the .pl script must read:

• #!/usr/bin/perl• NOT #!/usr/local/bin/perl

Change script name to “name.cgi” • The .pl tag is not recognized on the server. • Only scripts with the .cgi tag will run

properly.

Page 9: Making Your Web Page Interactive with CGI

Customizing ScriptsThe absolute path should be structured

as follows:• /mnt/web/guide/worldwidemart/scripts/• /home/lvcc/lvcc/www/cgi-bin/

The url path to the designated file is the full path:

• http://tln.lib.mi.us/~lvcc/cgi-bin/scriptname.cgi• http://tln.lib.mi.us/~lvcc/relatedwebpage.htm

Page 10: Making Your Web Page Interactive with CGI

Uploading Files

Page 11: Making Your Web Page Interactive with CGI

Creating the CGI Directory and Uploading Files

The CGI-BIN Directory Working in your FTP software:

• Open your www directory• Create a new folder at the host within the

www directory.• Name the folder cgi-bin

Uploading Files Working in your FTP software:

• Upload .cgi files to cgi-bin directory• Upload .htm files to the regular www

directory

Page 12: Making Your Web Page Interactive with CGI

Setting Permissions

CHMOD

Page 13: Making Your Web Page Interactive with CGI

Changing Read/Write/Execute Access for CGI Files

Permission settings for each associated file depends upon the action of the script.

The readme file will usually tell you which permissions to assign to each file.

Page 14: Making Your Web Page Interactive with CGI

Chmod in Linux/Unix

drwxr-xr-x 2 lvcc users 1024 Jan 15 10:02 cgi-bin-rw-r--r-- 1 lvcc users 1213 Jul 17 1996 momdad.htm-rw-r--r-- 1 lvcc users 6520 Jul 2 1998 money.jpg-rw-rw-rw- 1 lvcc users 2968 Jan 7 19:15 mypet.htm-rw-r--r-- 1 lvcc users 1942 Jun 22 1998 mypetadd.htm

-rw-r--r-- 1 lvcc users 394 Aug 5 09:54 folks02.gif-rwxr-xr-x 1 lvcc users 24292 May 11 1998 formmail.cgi-rwxr-xr-x 1 lvcc users 11340 Jun 22 1998 mypet.cgi-rwxr-xr-x 1 lvcc users 11380 Jan 14 1998 pineknob.cgi

Www Long List of Directory

Cgi-bin Long List of Directory

Page 15: Making Your Web Page Interactive with CGI

Changing Read/Write/Execute Access for CGI Files

Who Opcode Permission

u user + add r read

g group - remove w write

o other = assign x execute

a all

chmod u=rwx,g=rx,o=rx form.cgi

Page 16: Making Your Web Page Interactive with CGI

CHMOD by Numbers

Readme files will often use numbers to designate chmodsettings. • First digit = u• Second digit = g• Third digit = o• 4 (r) + 2 (w) + 1 (x) = 7 • 4 (r) + 1 (x) = 5chmod u=rwx,g=rx,o=rx form.cgi andchmod 755 form.cgi result in the same action.

Page 17: Making Your Web Page Interactive with CGI

Running The Script

Page 18: Making Your Web Page Interactive with CGI

Testing and Troubleshooting

Scripts must be uploaded and permissions changed before they can be tested.

Usually, a minor adjustment will correct script error messages. Incorrect directory information or a

misplaced slash will prevent a script from running.

Page 19: Making Your Web Page Interactive with CGI

Common Error Messages

Page 20: Making Your Web Page Interactive with CGI

The Form Mail Script In Action

Page 21: Making Your Web Page Interactive with CGI
Page 22: Making Your Web Page Interactive with CGI