Skip to content Skip to site navigation

CGI: Frequently Asked Questions

Table of contents

I'm wondering about running scripts using some interpreter that's not Perl or PHP. How do I do it?

Your CGI programs can be any executable for the server OS, but if it requires an interpreter it will only work if the interpreter is installed on the machine. Currently only Perl, PHP, and Python are officially supported. For Perl put "#!/usr/bin/perl" as your first line in the script. For PHP you do not have to add a line.

Using the suexec debug mode, the error says No such file or directory: exec failed even though the permissions are correct.

Open your script in vi, and make sure it does not contain ^M characters on ends of lines (this happens when you ftp files, or copy into AFS from Windows). If it does, run this command at the Unix command-line to convert the file:

dos2unix <current_name> <new_name>

How can I send email? I can't find the sendmail program.

For sending email, direct SMTP connections can be utilized. A sendmail emulator is available to CGI scripts at the path /usr/sbin/sendmail but is not guaranteed to work. You can also use Perl modules to send mail; see the Net::SMTP example on the Example CGI Scripts page.

Important: Please be aware that it violates Stanford security policy to allow users of your scripts to freely set the recipient address or in any other way abuse the emailing capability of the CGI service. It is recommended you only use this feature to send administrative notifications to yourself.

What logging is available?

The error log is no longer available for online viewing due to increasing privacy concerns. Users are advised to take advantage of the suexec debug mode, described in the Debugging Programs. If you do need to know what is in the error logs, file a HelpSU and we can work with you to get the part of the error logs relevant to you.

Last modified March 10, 2010