CGI/PERL FAQ
1.What is a cgi-bin?
A cgi-bin is a special directory designated in the config files of a web server
to allow execution of CGI scripts in specified directories. Many new servers
have done away with this and allow users execute any scripts ending in .cgi.
The cgi-bin is used to help keep systems secure. Keeping CGI scripts limited
to trusted users is necessary since CGI opens up a lot of security risks. Therefore,
most web platforms allow only files inside of a cgi-bin to be executed.
2. Do I need a cgi-bin to run these scripts?
Yes and No. A cgi-bin is needed to run these scripts unless your system administrator
has turned on ExecCGI, which enables .cgi extensions to be used in any directory.
To find out if you can use CGI scripts, your best bet is to ask your system
administrator if you can. He may opt to give you a cgi-bin in your directory,
turn on ExecCGI or check your script and then place it in the server cgi-bin.
3. What does "Internal Error: execve() failed" mean?
Most likely the path to your Perl interpreter is incorrect. This means that
the line:
#!/usr/bin/perl
located at the top of your perl file, needs to be changed to the correct path.
You can find the location of perl with command "which perl" or ask
your server administrator.
4. What does chmod xxx mean? What is chmod?
Chmod is a Unix command which changes the security settings for particular
files, giving users and groups permission to read, write, and/or execute certain
files. For many of my scripts, the uid (User ID) that the web server is running
under must either execute (in the case of the perl scripts) or write or read
certain files. There are several different cases in which different chmod commands
will be used. For example, any of the perl scripts that must be placed into
the cgi bin, must also be executable by the web server. This means you must
use:
chmod 755 filename.pl
This allows anyone to read and execute your file and it allows you the permission
to write to it. Any of the files that are automatically updated by perl scripts,
must be writable and readable by all, including the web server uid. Unless you
have super user access, this means setting your files to:
chmod 777 filename.[html|txt]
This will allow everyone to write to your files.
While using a FTP client software like Cute FTP, please note that these also
can be used to execute the "chmod" command. For example, in Cute FTP
the procedure is to upload the file in ASCII mode, select the file and then
right click on the mouse to get the "chmod" screen. Then one can simply
type in "755" at the text box and save the configuration.
5. Everything works, but when I turn on the mail option, it errors
out nor do I receive any data
First check your mail path. This often happens to users because of one of two
problems. Either they haven't corrected the sendmail path or their email address,
or they don't have sendmail.
A. Check path to sendmail and mailing address - Remember if you turn on the
mail option you must set two new variables. The $mailprog variable and the $recipient
variable. Many people run into the problem on the $mailprog variable, because
they forget to change this. Many systems do not have sendmail in the /usr/lib
directory which is default in my scripts, and some don't even have sendmail!
To find out where its located on your system, use the following command at your
unix prompt:
# which sendmail
This will tell you where sendmail is on your system. If it says it could not
find it, you don't necessarily not have it, just ask your system administrator.
The other common problem is to make sure that you have set your email address
correctly.
B. The second most common error is that your system doesn't have sendmail.
If this is the case, ask your system administrator what mail programs you do
have that you can send mail from a cgi program with? Some of them are: mailx,
mail, etc... You can use the which command for these as well. If anyone has
a patch for mailx or whatever, send it to me and I will put it here.
|