To create a CGI script, you must create a marker for it in your public_html directory. The marker is just an empty file.
The CGI script must have exactly the same name as the marker but with /cgi added onto the front of the path. If the marker's name is /home/john/public_html/fancy.cgi, then the CGI scripts name is /cgi/home/john/public_html/fancy.cgi.
For example:
CGI scripts must be named something.cgi.
While your script is running, it will only have access to files that are under /cgi. Only a subset of the programs available on Idiom are available on /cgi. In particular, sendmail is missing. There is a simple sendmail replacement on /cgi though in /cgi/usr/sbin/sendmail.
We recommend writing your CGI program in perl5. See man CGI for CGI-related perl functions. If you need to send email from your CGI, then see man Net::SMTP. For general perl reference, see:
If you are going to write more than a few CGI scripts, it may
make sense to put your web pages in /cgi and then make a link
to them:
If you have a virtual host, then put your scripts in /cgi/home/USERNAME/www.YOUR-DOMAIN. Put your touch files in /home/USERNAME/www.YOUR-DOMAIN. The URL for your cgi scripts will be http://www.YOUR-DOMAIN/SCRIPT.cgi
Although it is not recommended, if you wish to use the
uncgi
program, version 1.8 is installed.
You must make a touch (see above) for uncgi.cgi, but not
for the programs that it calls. To use it, go to the
directory that your script will be in and give the following
command:
Put all your cgi pages in $HOME/public_html/cgi (which is now the same thing as /cgi/$HOME/public_html/cgi). If you are using another.idiom.com, then a similar link (for your whole public_html) is already in place.
To test CGI scripts by hand from the inside of the chroot()ed environment, use the cgishell command.
Cgishell can be found at /usr/local/bin/cgishell. It starts a shell inside the /cgi directory.
The URL for your CGI scripts is http://www.idiom.com/user-cgi/LOGIN/SCRIPT-NAME
There is one benefit of this setup: better information when your program bombs. In your script, don't output anything until the very last line. Save it in a buffer. Save another buffer filled with debug information. If you exit with die then the die message, and the variable $elog will be displayed.
The CGI.pm module is available for CGI programming.
If you need to send email from a CGI script, the Net::SMTP.pm module is a good approach.