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

i posted this before, but i didnt get much of a response, so I'll post it more in detail this time. sorry if this annoys anyone, please dont be POed...my site structure is like this:
html (the root directory) | |--index.htm | |--cgi-bin | |--serve.cgi | |--ads | |--ads.cgi
now, in both index.htm and serve.cgi, is the ssi tag: <!--#exec cgi="/cgi-bin/ads/ads.cgi" --> in index.htm, the ssi tag works fine, but in serve.cgi, all i get is [an error occurred while processing this directive]. i tried changing the path in the ssi tag to "/ads/ads.cgi" in the script, but that didnt work.

I'm on a freebsd 4.2 server with perl v5.005_03 for i386-freebsd. i tried Option +Includes and #exec cmd too, and that just gave me a bunch of 500 errors.

i even tried moving index.htm to a subdirectory of /html, and serve,cgi to the same subdirectory, and the tag still worked in index.htm, and it still DIDNT work in serve.cgi. i'm all out of ideas, any help would be greatly appreciated.

______________________________________________
RIP
Douglas Noel Adams
1952 - 2001

Replies are listed 'Best First'.
Re: SSI help...
by LD2 (Curate) on Jun 01, 2001 at 09:18 UTC
    Take a look at CGI::SSI again. In the previous discussion, dws mentions using <!--#exec cmd=""-->.. which is correct based on the CGI::SSI documentation.

    <!--#exec cgi="..."--> is no longer being supported. But <!--#exec cmd="..." --> is supported, but "the package variable CGI::SSI::allow_exec has to be set to true (and will fail in any case if your CGI is running in taint mode, as it should be!)."
      I AM using CGI::SSI and I tried using cmd instead of cgi. I also tried using Option +Include in the .htaccess file.

      update:

      Also, i realized, im using an older version of CGI::SSI than the one you're pointing at...no, wait, im using a newer version, im using v.51, you're pointing me to v.01 the version i'm using DOES support exec, but it doesnt have the allow_exec variable in it.

      ______________________________________________
      RIP
      Douglas Noel Adams
      1952 - 2001

Re: SSI help...
by thpfft (Chaplain) on Jun 01, 2001 at 15:21 UTC

    I've been through a similar process trying to get layout scripts to work with both static and cms-generated pages, and i don't really recommend the post-parsing approach. Apart from anything else, you're going through the whole inefficient cgi process twice.

    It's going to be much easier and more efficient if you modularise your code a bit.

    Put the ad script in a module. In the simplest case it'll all be in a single sub called make_ad(), or something like that. Then replace your ads.cgi script with a very short one:

    #!usr/bin/perl; use Ads::Mymodule; print "Content-type:text/html\n\n"; print Ads::make_ad(); exit;

    You may need to pass parameters to the sub, of course. You can then use the same mechanism in your serve.cgi. Where you used to say:

    print qq|<!--#exec cmd="/cgi-bin/ads/ads.cgi"-->|;

    and then parse it out again and run the ad script, all you need is:

    print Ads::make_ad();

    And the outcome is the same: no extra steps and no duplication of code. There are good tutorials around for module-building, including perldoc perlmod.

    Incidentally, the included ads.cgi needs to print the mime-type header on Apache, but not on IIS, as i recall.

Re: SSI help...
by Beatnik (Parson) on Jun 01, 2001 at 12:46 UTC
    Altho I'm not SSI fan (I barely use it), you might want to check <!--#include virtual="..." -->.
    What happens if you use <!--#exec cgi="ads.cgi" --> in your CGI script?

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.