Dealing With CGI Installation Jitters
If you get the jitters just thinking about installing a CGI program, this article is for you.
The best way to get over the jitters, that I know of, is to go ahead and install one. This article has a four-line script you can use to practice with.
Two things to remember when working with scripts
Of course, you'll need to have a directory on your server that is allowed to run Perl CGI programs. These directories are often referred to as the cgi-bin, and sometimes the directories even have that name. Other common names for the cgi-bin are "cgi-local" and "cgi". If unsure, ask your hosting company.
- 1. When editing Perl CGI scripts, always use a plain text word processor. NotePad (PC) or BBEdit (Mac) are your friends.
- When uploading Perl CGI scripts, always do so with an FTP program and transfer the file in plain text mode (as opposed to binary mode).
Using methods other than FTP, such as FrontPage or even some so-called "upload control panels" can break scripts. If you don't have an FTP program, tucows.com lists several.
"FTP" means "File Transfer Protocol." Use the tool for the job.
If your hosting company does not allow you to run CGI scripts, you might consider opening an account with one who does. Free hosting like that available from Hypermart is an option, especially when getting started and wanting experience to help make future hosting decisions.
Time to Practise!
Here is the 4-line script you can practice with
$Message = "<h1>Congratulations, my friend!</h1>";
print "Content-type: text/html\n\n";
Copy and paste (or type) the above 4 lines into NotePad or BBEdit. Save the file as practice.cgi (or something.cgi if you already have a file named practice.cgi on your hard drive or on your server).
Verify that the first line of the script is correct. It must start with the characters #! and be followed with the location of the Perl interpreter on the server. Your hosting company can tell you that location. The correct line is probably #!/usr/bin/perl or #!/usr/local/bin/perl
Use your FTP program to upload practice.cgi onto your cgi-bin.
Once uploaded to your server, the script needs permission to run. Some servers are configured to automatically set the correct permissions when scripts are uploaded. If yours doesn't, set permissions to global execute. That is
user - read/write/execute
group - read/execute
other - read/execute
which corresponds to permissions number 755. Your FTP program is the tool to use for setting permissions. Different programs have different methods of doing so, but most have either checkboxes where you can select according to the list above or a place where you can type in the permissions number. If your FTP program requires a 4-digit number, use 0755.
For a more extensive discussion of "permissions", see the "Unix/Linux File Permissions" article linked from http://willmaster.com/possibilities/archives/
To run practice.cgi, type its URL into your browser, something like this
If everything works as it should, you should see
Congratulations, my friend!
in your browser window.
If it doesn't work, try the installation process again; start from the beginning with a clean slate. The error might have been something overlooked or a simple mistake.
If it still doesn't work try one of these resources
The FAQ at http://mastercgi.com/faq/ lists the common reasons for installations to fail.
Even if things go well with practice.cgi, consider buying "How to Install CGI Programs" ($12.95). It is a great tutorial and could be indispensable for future installations.
The "How to Install CGI Programs" ebook written by your author (published by Intellectua) and obtainable from http://willmaster.com/a/15/pl.pl?pie1 has lots of additional information.
Now that you've installed practice.cgi, you might try your hand at editing it. Change the message to something with your name in it, for example. Then do another change, like adding an HTML horizontal rule tag <hr> into the last line of the script, before or after the $Message variable.
To increase your confidence, install some of the scripts from the Master Series at http://willmaster.com/master/ Master Feedback and Master Recommend, both free, are fairly easy to install and provide basic functionality every web site should have.
The more you work with scripts, the more confident you will become.
And when you're filled to the brim with confidence and want to tackle writing your own script, read the 4-part "Writing Your Own Form Handling Scripts" series linked from http://willmaster.com/possibilities/archives/
- Copyright 2004 Will Bontrager * All rights reserved -
About the Author:
Copyright 2004 Bontrager Connection, LLC
"WillMaster Possibilities" ezine
Site Navigation Guide
Site updated daily
Free Insider Report|
Receive free monthly marketing updates, tools, tips and strategies to help your online business succeed. Get immediate access to our bonus ebooks AND 150+ back issues.
PRODUCT OF THE WEEK
Copyright © 2000-2009 by Startup Internet Marketing Services* All rights reserved|
104 Main Street. Kirkland Lake, ON, CA P2N 3E8 705.567.5850
This site is powered by Host4Profit.net