MEGAN'S NOTEBOOKS //
HTML Tags //
CGI & FORMS //
Common CGI Script Errors
If none of the following helps, email me and I'll try to help.
A directory on your server that can run them. That directory must be
ScriptAliased or ExecCGI-enabled. Your server administrator can tell you this.
- What do I need to process cgi scripts?
- What are all these weird ^M's in my script after I FTP'ed
Always use ascii or text, never binary mode to transfer
to the server . If you still get ^M's edit them out with vi like
Ctrl v Ctrl m
thatís a one not a ell, and Ctrl v Ctrl m
Macintosh files can be converted to UNIX-style files buy
using the following command line on UNIX:
tr '\015' '\012' < oldfile.html > newfile.html
- How do I make my scripts executable ?
On servers that allow CGI you must set the file permissions
chmod 755 scriptname
or, if you are using a ftp client that allows sending ftp commands
site chmod 755 scriptname
local 'chmod(1)' man page if you need help with setting permissions.
Try running your script from the command line. It should
execute without errors. If it has errors fix them.
- My script doesn't work!! I get a "malformed header
- Ok, I have the script executing, but no data comes back!
1. The first line of your code (in perl anyway) should be
If that's not the location of PERL, try typing which perl at
the command line, it will return the full path to perl on your server.
For a shell script it probably needs to be:
2. You could be forgetting to send back headers.
This needs to be in any script that sends back any HTML:
print "Content-type: html/text\n\n";
#two new line characters needed, that's what the \n\n; is for in Perl.
If it's a shell script use:
echo Content-type: html/text
- I can't get my CGI to write to my file! Help!
If your cgi writes data to a file make sure that the files
permissions are world writable.
chmod 666 filename
Check and recheck your paths. They must be right on. If you snagged the script straight of the net or someone e-mailed it to you (versus unpacking it from a tar or
zip file) double check the syntax closely. If it doesn't run at the command line, it won't
run on the web server.