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

In the .htaccess file, I put AddType text/x-server-parsed-html .htm to do it for .htm files, but is there a way to do it with .cgi and .pl files? and AddType text/x-server-parsed-html .cgi doesnt work...i tried.

Replies are listed 'Best First'.
Re: How do I get cgi scripts parsed for ssi by way of the .htaccess file?
by Masem (Monsignor) on May 31, 2001 at 02:01 UTC
    If you are trying to have the results of a CGI file (that being an HTML stream) re-parsed to handle SSI directives, you cannot do it; the CGI output is sent directly from the script to the outside connection, and no further parsing is done by the web server. Instead, you need to do the parsing during the CGI output generation, typically with a module like CGI::SSI or the like.

      I tried CGI::SSI, but when I do an exec i get "An error has occured" or whatever. Then i tried an include virtual and I got the source code of the script (dont ask me how that happened). the script is chmodded 755, all the paths are right, so I dunno what's wrong...
        You may need   Option +Includes in your .htaccess . Then,   <!--#exec cmd="./foo.pl"--> will work. CGI-style exec is left as an exercise (it's there in the Apache docs).

        It probably would be helpful to post the code that you are working with so that we can find what errors you might have.
        Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
Re: How do I get cgi scripts parsed for ssi by way of the .htaccess file?
by EvanK (Chaplain) on May 31, 2001 at 21:21 UTC
    i'm just gonna go over everything again and hope someone can help me...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.

    ______________________________________________
    When I get a little money, I buy books. If I have any left over, I buy food and clothes.
    -Erasmus