View Full Version : Problem Parsing CGI-Bin

01-11-2008, 11:16 AM

I have a forum that is in the cgi-bin. I am wanting to use my existing site wide navigation system that is based on ssi, for the forum.

I have read several posts but I haven't gotten the include to be parsed yet.

I must be overlooking something simple, so please help me to get the ssi includes to display on a .cgi page.

Here is what I have for my cgi-bin virtual directory in the httpd.conf file:

<Directory "/var/www/cgi-bin">

Options FollowSymLinks MultiViews Includes ExecCGI
AddHandler cgi-script .cgi .pl .py .sh
AllowOverride All


In my root I have this .htaccess file:

AddHandler server-parsed .html .cgi
ErrorDocument 404 /notfound.html

I am using this link to call the ssi include:

<!--#include virtual="footer.html" -->

footer.html is in the same directory as the cgi script I am using.

Please tell me what I am doing wrong so that I can get the include to display on the forum.



01-11-2008, 04:04 PM
Your mixing two types of "Handlers". I don't think you can have both.

If footer.html is simply HTML for the bottom of your page then then you would want to assign the content of that file to a variable then print it out.

It is hard to know how to direct you more without knowing more about the script and what you need.

01-11-2008, 04:21 PM
Thanks for getting back to me.

My specifics are as follows:

I have a site that has .html pages and uses ssi to provide all navigation elements (header, footer and left navigation). You can see the site at http://www.thefrugallife.com

It seems when I try to reference a page in the cgi-bin it quits. That is what I want to get working. Because, I have a forum at http://www.thefrugallife.com/cgi-bin/yabb/YaBB.cgi

that has the same navigation elements but they are hard coded and not being called by a ssi.

If you need more let me know. I don't know the significance of either add handler statement so they may be able to be changed.



01-11-2008, 04:39 PM
The AddHandler tells the server what "language" to use to interpret files. The server can not use two different interpreters or parsers on the same type of file.

I am trying to bone up on my cgi at the moment. :) You are going to want to use the open command to get the footer.html file and then assign it to a variable then close the file and print the variable. I remember how to open and close a file but can't rember how to assign the open file to a variable. :) I'll let you know when I figure it out.

01-11-2008, 04:54 PM

I think the confusion lies here:

so please help me to get the ssi includes to display on a .cgi page.

Normally, there is no such thing as a .cgi "page". Cgi files are usually scripts or programs, commonly written in Perl or another scripting language. The output of the script is what is sent to the user's browser and that is what is displayed.

The mechanism represented here

<!--#include virtual="footer.html" -->

is a server side include, or ssi. Generally speaking, ssi's are not processed in pages generated by a cgi script.

There are ways to have your cgi script read the footer.html file and insert the html into the script output. We'd have to know what language your script is written in to give you pointers.

In perl, you could use something like this:

open(INCL, "footer.html");
while(<INCL>) {
$content .= $_;
close (INCL);

and then use the $content variable in the output of your script.

I hope this helps.

01-11-2008, 05:21 PM
Thanks Bruce for supplying the code needed. I was almost there but would have come up with more lines of code I think. :)

P.S. Now I remember why I moved to PHP as my language of choice.

01-21-2008, 03:18 PM
Thanks for setting me straight. I had lost sight of the fact that there are no cgi pages. Now I know what can be done I will have to go a different way.

Thanks again,