Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Though not 100% related to Perl, it is about Perl and I know one of you wise monks can help me out.

I have a new website and I want to include a perl chat script in a specific table on every page. I can get the SSI to work perfectly if the files calling the chat script are in the main directory. But if I call the chat script from a different file than my main directory, it can't find it.

<!--#include virtual="/home/richards/public_html/cgi/chat.cgi"-->
That's the code I am trying to use to call the CGI script. This is on a sub domain (cgi.domain.com) so that's why there's a folder /cgi/, but it's the main folder on this sub domain.

It works for all files calling the chat script in the /cgi/ folder but anything outside this folder (ie: /cgi/tutorials/, /cgi/about/) can't locate it.

This is an example of the error using the exact code as shown above.

unable to include file "/home/richards/public_html/cgi/chat.cgi" in pa +rsed file /home/richards/public_html/cgi/tutorials/index.shtml
Does anyone know what I did wrong? The file path IS right.

Thanks.

Retitled by davido.

Replies are listed 'Best First'.
Re: OT: Using global SSIs
by saskaqueer (Friar) on Jan 14, 2005 at 05:35 UTC

    I may be off on this a little, but from what I remember from way back, the path you use for the 'virtual' clause should be from the server root, not an absolute path on your filesystem. This doesn't explain why it would work in the server root but not in a subdirectory, but maybe I'm right anyway. Try one of these (it should be the first one if chat.cgi is in the server root as you say it is):

    # try this one first <!--#include virtual="/chat.cgi"--> # if that doesn't work, maybe this: <!--#include virtual="/cgi/chat.cgi"-->
      The first would would work, I know that without testing. I just have a lot of subfolders and folders inside of subfolders and I'd hate to have to have each SSI statement fixed. Is there no absolute path one?

        Well, this site on Apache SSI's #include offers the file= parameter. Now, this can't be absolute paths, but it can be relative to the physical filesystem (just not '../').

        However, the virtual= parameter allows you to use absolute paths -- it's just that the 'root' is the DocumentRoot, not the filesystem root. If you're using this script with multiple virtual servers on the same machine, you can use a ScriptAlias or Alias in your Apache config to make sure, e.g. that all references to "/chat/" on any virtual host will access "/home/legato/scripts/chat/". Adjust as needed, of course.

        radiantmatrix
        require General::Disclaimer;
        s//2fde04abe76c036c9074586c1/; while(m/(.)/g){print substr(' ,JPacehklnorstu',hex($1),1)}