The Idiot's Guide to Solving Perl CGI Problems 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. _________________________________________________________________ Q: Who owns the script? A: I do. Q: What are the script's permissions? A: They were 0600, but I just realized that's not executable. I'd better make it 0755 instead. Q: Is your script in the right directory? A: No, I forgot to put it in /usr/local/etc/httpd/cgi-bin/. Q: Is CGI execution enabled in your server for that directory and/or file suffix? A: No, my sysadmin forgot to configure it that way; he thought that GET would be enough, and didn't include POST capabilities. Q: Under what uid does the server runs its CGI programs? A: wwwuser (Oops, it can't write my files or directories.) Q: Can the server's uid write any files you're trying to write? A: 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. Q: What happens when you run it interactively? A: I didn't know you could run these interactively because I never bothered to read the documentation for the CGI.pm library. Q: What's in the server error log? A: I never thought to look. Oh, there it is - never mind. Q: Where's the server log? A: (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) Q: What's the Perl version and OS version? A: Perl version 5.002, SunOS version 4.1.3 (Try using perl -v and uname -a to find out, and if your Perl is below 5.002 in version, UPGRADE NOW!) Q: What's the library version? A: grep -i version in the library, or for CGI.pm, do this: $ perl -le 'use CGI; print $CGI::VERSION' 2.21 Q: What's the path to your perl executable on the server? A: /contrib/bin/perl Q: What's the path to your perl executable specified in your script? A: /usr/bin/perl (oops, of course it can't find it) Q: What's the http daemon server's version number so people who might help you have a better clue about your local environment? A: NCSA 1.5 Q: What happens when you add Perl's -w flag? A: It tells me about my silly mistakes that are listed in detail in the perldiag manpage where I diligently looked them up. Q: What happens when you add Perl's -T flag? A: It tells me about security problems as described in the perlsec manpage, which I've carefully read and understood. I even read the CGI Security FAQ. Q: What happens when you add use strict? A: It makes me declare my variables and quote my strings and finds all these silly errors which I've carefully corrected using my() declarations, use vars, and quotes. Q: Did you remember to output the MIME type before any other non-header output (other headers might be Location: or Set-Cookie:) A: Oh, right. It has to be a valid header and then a valid body. I guess I need to say this stuff earlier than I was doing: and make sure I actually put two newlines out, not just one. print "Set-cookie: GroversDelight\n"; print "Content-Type: text/html\n\n"; # <-- two newlines print "