cgi

 

I'm not an expert on cgi, but I have used it to add header, footer and navigation information for Élodie's website. I've also used it here on my own site for the header, footer and sidebar. It's handy for that - so you can keep repeating information in one place only. I just used a standard script that I got from an HTML class I took at Foothill College which simply prints a text file contaning the HTML code to be inserted. Here's what you need to make it work:

  • Your webpage must be .shtml file type.
  • You must give file permissions of octal 755 to the cgi script file.
  • You must use relative, not absolute referencing to direct your .shtml file to the cgi script file.

So, for example, to produce the footer on each page, the .shtml file contains the line:

<!--#exec cgi="./cgi-bin/dm_footer.cgi"-->

This calls the cgi script dm_footer.cgi:

#!/usr/local/bin/perl -w ############### # Footer # # by Mike Wheeler # # Command-O Software # # Copyright 1996 #put this on page you want footer to appear # All Rights Reserved ############### $footer_file = "dm_footer.txt"; print "Content-type: text/html\n\n"; open(FILE,"$footer_file"); while ( ) { print $_; } exit;

This prints the contents of dm_footer.txt (below)

<div id="footer"> <p>© 2011 Deirdre Moore. Based on <strong>Orangemint</strong> design by <a href="http://www.freecsstemplates.org/"> Free CSS Templates</a>.</p> </div>