From: Tom Christiansen <tchrist@mox.perl.com>
Date: 20 Jun 1996 15:42:57 GMT
Newsgroups: comp.infosystems.www.authoring.cgi,comp.lang.perl.misc
[ Thanks for all the input -- here's an update. I've directed
followups to the CGI group. ]
If you're like most people on the newsgroup, you've presented us with
the clasiquísimo CGI problem: "it doesn't work", without providing us
sufficient background to divine what the real problem is. This is
infuriating, because is makes you come off like some drooling idiot
begging for free consulting help without having done any investigation
on your own part. This drives people away who could otherwise help you
and impoverishes the Net by exacerbating the already annoyingly low
signal-to-noise ratio.
For a start, you need to look through the checklist below for a few simple
questions that need answering. While some sample answers are provided,
you'll have to figure them out on your own.
=========================================================================
Who owns the script?
e.g. I do.
What are the script's permissions?
e.g. 0755
Is your script in the right directory?
e.g. No, I forgot to put it in /usr/local/etc/httpd/cgi-bin/.
Is CGI execution enabled in your server for that directory
and/or file suffix?
e.g. No, my sysadmin forgot to configure it that way.
Under what uid does the server runs its CGI programs?
e.g. wwwuser (Oops, it can't write my files or directories.)
Can the server's uid write any files you're trying to write?
e.g. Nope -- I own the files, but it doesn't run as me
and the permissions are 0600 instead of 0666. I
guess that's why it can't open my own files.
What happens when you run it interactively?
e.g. I didn't know you could run these interactively
because I never bothered to read the documentation
for the CGI.pm library.
What's in the server error log?
e.g. I never thought to look. Oh, there it is -- never mind.
Where's the server log?
(No way to know -- it's system dependent. Check with your
admin if you can't find it in /usr/local/etc/httpd/logs/error_log)
What's the Perl version and OS version?
(try perl -v and uname -a)
e.g. Perl version 5.002, SunOS version 4.1.3
(if your Perl is below 5.002 in version, *UPGRADE NOW*)
What's the library version?
e.g. grep -i version in the library, or for CGI.pm, do this:
$ perl -le 'use CGI; print $CGI::VERSION'
2.21
What's the path to your perl executable on the server?
e.g. /contrib/bin/perl
What's the path to your perl executable specified in your script?
e.g. /usr/bin/perl (oops, of course it can't find it)
What's the http daemon server's version number so people who
might help you have a better clue about your local environment?
e.g. NCSA 1.5
What happens when you add Perl's -w flag?
e.g. It tells me about my silly mistakes that are listed in detail
in the perldiag manpage where I diligently looked them up.
What happens when you add Perl's -T flag?
e.g. It tells me about security problems as described in the
perlsec man page, which I've carefully read and understood.
I even read the CGI Security faq in
http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html
What happens when you add `use strict'?
e.g. It makes me declare my variables and quote my strings
and finds all these silly errors which I've carefully
corrected using my() declarations and quotes.
Did you remember to flush STDOUT via $| = 1 at the top of your script?
e.g. Nope; gosh, no wonder it doesn't get out before it bombs.
What happens when you check return values of EACH AND EVERY ONE
of your syscalls, probably with something like
open(FILE, ">some_file") || die("can't write some_file: $!");
e.g. it show that $! contains "Permission denied" or
"No such file or directory".
Did you use the standard CGI.pm module to do this for you instead of
parsing by hand (which would be a really idiotic idea) or use the
more limited cgi-lib.pl library?
e.g. No, I didn't know I didn't have to recreate the wheel
(badly) and that I could get the neat CGI module from
http://www.perl.com/cgi-bin/cpan_mod?modules=CGI
If you used a library, did you type "make install" to place it in the
proper system directory (somewhere in @INC, probably a lot like
/usr/local/lib/perl/site_perl/CGI.pm) so it can be properly found and
have its set permissions to 0644, or did you just blindly do a manual
copy and screw up the path, permissions, or both?
e.g. What's make? Looks like I just misinstalled it myself by
a silly copy to cgi-bin and then I made it mode 0700.
I guess that doesn't work at all, does it?
Did you remember to post to comp.infosystems.www.authoring.misc,
instead of blasting the comp.lang.perl.* groups with questions
that aren't related to Perl in the least?
e.g. Nope -- is that why I don't get any useful answers but
just a bunch of flames instead?
If you're running some brain-dead, bondage-and-discipline pseudo-
operating system from The Evil Empire, did you bother to read what
the Windoze Perl FAQ says about the Web?
e.g., No, I didn't know about http://www.perl.hip.com/PerlFaq.htm
Did you avoid placing an interpreter in your cgi-bin the way CERT
and http://www.perl.com//perl/news/latro-announce.html warn you about?
e.g. No, what's wrong with that? (noise of disk grinding to
dust after corporate secrets stolen heard in the background)
=========================================================================
Odds are that if you'd merely answer these questions and carry out the
specified steps, you yourself would solve your very own problem without
having to come begging for help and pissing off the Net.
Once you have thoroughly investigated *ALL* of these matters on your own
and perhaps even asking your buddy in the next cubicle whether he's seen
anything like it, should you find that it's still a problem, then by all
means please go ahead and post, but do make sure you give us plenty of
details, including your own answers to all (or at least most) of the
questions listed above.
On the other hand, if most of those questions don't even begin to make the
least bit of sense to you, you're already in way over your head. If this
should be the case, you'd better hold off on CGI programming and go find
yourself a local guru and check out some of the many books listed at
http://wwwiz.com/books/cgi-perl.html
IM!HO, the Addison-Wesley and O'Reilly books tend to be the most thorough,
but there are so many out there that you'd do well to look them over
yourself. Remember that thickness needn't imply clarity, completeness,
or correctness.
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
"With a PC, I always felt limited by the software available.
On Unix, I am limited only by my own knowledge." --Peter J. Schoenster
From John's Useful Posting Archive (JUPA)
Maintained by John Callender
John's Home Page
Archive created with babymail