[an error occurred while processing this directive]
Introduction to Perl.
Preparing the template.
-
Create a folder on your Mac or PC hard drive called perltour
-
Click here to load the text file, template.txt.
Save it to the perltour folder as template.txt.
Choose File:Save As and select the perltour
folder. Then click the Back button.
-
Open the file in your favorite word processor - it should save as plain
text. The one you use to edit HTML code is probably a good choice.
-
Replace everything after the exclamation point on the first line
with the path to Perl which you located earlier.
[Windows NT Users: Remove the 1st line.
Your machines use the .pl filename extension to locate Perl, so it is important
that you name your files filename.pl and not filename.cgi]
-
Locate the 8th line from the end of the document, which reads
open(MAIL, "|/usr/lib/sendmail -t") || die
-
Replace the text /usr/lib/sendmail
with the path to sendmail which you located earlier.
-
Locate The text on the next line which reads
"Content-type: text/text\n\nCan't open /usr/lib/sendmail!";
-
Replace the text /usr/lib/sendmail with the path to
sendmail.
-
Save the file.
From now on you will be able to copy template.txt every time you want to
create a new CGI.
Creating a test file
We will now create a test CGI and upload it to the server.
NOTE: Some servers allow your CGI programs to be anywhere in your web
directories, so long as the file name ends in ".cgi". Others require you
to put them only in the "/cgi-bin" directory. Check with your system administrator.
-
Make a copy of template.txt called test1.cgi (test1.pl on
Windows NT)
-
Open test1.cgi and locate the line which reads
#************BEGIN BODY*********
-
Position the cursor just below that line and type
print "<h1>Hello World</h1>";
-
Save test1.cgi
If you do not need to place scripts in a cgi-bin...
-
Use your Telnet program to log-in to your Unix server.
-
At the Unix command prompt, type mkdir perltour and press
[ENTER] to create a folder for your practice files.
-
At the Unix command prompt, type chmod a+rx perltour and
press [ENTER].
-
At the Unix command prompt, type cd perltour and press
[ENTER].
-
Use your FTP program to upload test1.cgi to the perltour
folder on your server.
NOTE: You should always upload your cgi files as ASCII, not binary.
-
At the Unix command prompt, type chmod a+rx test1.cgi and
press [ENTER].
-
At the Unix command prompt, type ls -l and press [ENTER]
You should see the file, test1.cgi with the privileges,
rwxr-xr-x , indicating that anyone can now read and execute this
file.
-
Launch your web browser, and point it to your home directory URL.
Add /perltour/test1.cgi to the end of the URL.
If you DO need to place scripts in the cgi-bin...
-
Use your Telnet program to log-in to your Unix server.
-
Ask your system administrator for the path to the cgi-bin.
-
At the Unix command prompt, type cd path to cgi-bin
and press [ENTER].
-
Use your FTP program to upload test1.cgi to the cgi-bin
folder on your server.
NOTE: You should always upload your cgi files as ASCII, not binary.
-
At the Unix command prompt, type chmod a+rx test1.cgi and
press [ENTER].
-
At the Unix command prompt, type ls -l test1.cgi and press
[ENTER]
You should see the file, test1.cgi with the privileges,
rwxr-xr-x , indicating that anyone can now read and execute this
file.
-
Launch your web browser, and point it to your server URL. Add /cgi-bin/test1.cgi
to the end of the URL.
For example, http://www.myserver.com/cgi-bin/test1.cgi
Hello World should appear in big letters, indicating that the CGI worked
properly. If it did not work, click here
to view some of the common troubleshooting techniques.
Congratulations, you just created your first CGI. Getting used to
Unix is the hardest part. The rest is easy. Hang on, we're
going to have some fun.
| |
|
|
Home | WebData - Web Database Software | Javascript | CGI
| Consulting | Map
Builder
| Contact Us | The Press
Room
|