Help - Search - Members - Calendar
Full Version: CGI Server Side Includes
Movable Type Community Forum > Additional Resources > Tips and Tricks
sigalarm
I am setting up a Moveable Type Blog, wonderful tool by the way.

One of the things I want in the right hand column of my blogs main page is an additional calendar that is generated by a CGI script.

I have the main page of my blog at the top of my website

http://www.somesite.org

and the cgi script I want to do is calpublisher.cgi  It is stored under a directory called calpublisher

so if I were to access it from a web browser it would be

http://www.somesite.org/calpublisher/calpublisher.cgi  

I can access it from a browser stand along with no problem, but I have had a beast of a time getting it to be included.  Any ideas on a good approach for that?

I have tried adding


<--#include virtual /calpublisher/calpublisher.cgi"-->

To no avail

Thanks for any and all hints

Bruce
kadyellebee
Because I'm not so familiar with SSI, I checked my best friend Google ( :giggle: ) and found SSI and CGI/

You might read over that and see if it applies to your situation - it looks like that your code is missing an = and a  quotation mark - but it might be the board eating it!
CODE
<--#include virtual="/calpublisher/calpublisher.cgi"-->


Hope this helps,
Kristine
staggernation
Some web servers don't allow you to call a script with the include SSI command, only a static file. Try this instead:
CODE
<!--#exec cgi="/calpublisher/calpublisher.cgi"-->

If that doesn't work, it may be that your web server is not set up to allow CGI includes. If that's the case, the next best thing would be to set up your script to periodically generate a text file, and call that file into your page with include virtual.
Muffinboy
SSI and PHP conflicts with using other cgi scripts, because there's some pre-processing being done on the webpage by the SSI or PHP engines.

I have found that using relative paths for CGI scripts almost never works, but if you use an absolute path, it sometimes will. However, this works only in PHP, since SSI only allows relative paths.

Luckily, there is an SSI tutorial with the answer:

QUOTE
exec executes a given shell command or CGI script. It must be activated to be used. Valid tags are:

cmd will execute the given string using /bin/sh. All of the variables defined below are defined, and can be used in the command.
cgi will execute the given virtual path to a CGI script and include its output. The server does not perform error checking to make sure your script didn't output horrible things like a GIF, so be careful. It will, however, interpret any URL Location: header and translate it into an HTML anchor.


So try this:
CODE
<--#exec cgi="/calpublisher/calpublisher.cgi"-->


I haven't tried this myself, so let us know if it works...
Muffinboy
heh... must have been only seconds late.
sigalarm
Thanks all of the help.  The real answer was.....

I needed to change the output of my main template to be .shtml instead of .html.

DUUUH!

The other stuff was good too, thanks

Bruce
staggernation
One other thing: your web server may be configured to process SSIs only on pages with a .shtml extension. If you load the page in a browser and View Source, and you see the <!--#include... tag in the source (instead of an error message or nothing at all), that may mean the web server isn't even trying to interpret your SSI calls in the first place. If that's the case, try renaming your page to .shtml , or look into changing your site's configuration so that SSIs will work on .html or .shtml pages (with Apache, for instance, this can be done using a file called .htaccess).

(On edit: guess I was the one who was just a few seconds late that time... glad you figured it out. As mentioned above, if you don't want to change your pages to .shtml, it shouldn't be hard to change the configuration.)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.