Here are two examples of a simple CGI script that displays a randomly selected image on a web page. The same script is presented here in C and perl, so that you can see how to implement scripts in either language.

You should put the executable C program (rand_images.cgi) and the perl script ( in /usr/www/cgi-bin. Use chmod to make sure that both files have 755 permissions.

The images that they access are actually located in /usr/local/httpd/images. The web pages access the images in their local directory; the CGI script just figures out which one it wants to load.

To run these scripts from a web page, use the following HTML with SSI commands:

<H2>Here is a random image</H2>
Perl Script: <!--#exec cgi="" --><BR>
C Program: <!--#exec cgi="rand_images.cgi" --><BR>