Forum Moderators: coopster & phranque

Message Too Old, No Replies

A question about Perl and SSI

Does not work properly

         

ebizcamp

9:33 am on May 16, 2004 (gmt 0)

10+ Year Member



I have a CGI program (main.pl) and one html file (header.html).

The main.pl file has many variables, say, main.pl?var1=a&var2=b. I have created a .htaccess to make it SE freindly, in this format, main_a_b.html and I always call the CGI file in this HTML URL format

Now, I want to include a cgi (new.cgi) file in the main.pl. First, I add this line to my htaccess

AddHandler server-parsed .html

Then, I add:


print qq~
<!--#exec cgi="new.cgi" -->
~;

to main.cgi. But it does not work. So I add

<!--#exec cgi="new.cgi" -->

to header.html, it works. But when I call header.html in main.cgi (through main_a_b.html) , the SSI does not work.

open HEADER, "header.html";
print <HEADER>;


I am very new to perl. I have searched for a while but I cannot find the answer. Any suggestion is highly appreciated. Thanks

ebizcamp

10:05 am on May 16, 2004 (gmt 0)

10+ Year Member



Oops! Right after I submitted this thread, I find in Apache.org that


9.How can I have my script output parsed?

So you want to include SSI directives in the output from your CGI script, but can't figure out how to do it? The short answer is "you can't." This is potentially a security liability and, more importantly, it can not be cleanly implemented under the current server API. The best workaround is for your script itself to do what the SSIs would be doing. After all, it's generating the rest of the content.

This is a feature The Apache Group hopes to add in the next major release after 1.3.

[webmasterworld.com ]
[webmasterworld.com ]

Both provide solutions. :)

flashfan

2:41 pm on May 18, 2004 (gmt 0)

10+ Year Member



Mine is working file. I am using Apache/2.0.47

I have a header.cgi, which dynamically loads keywords, meta tags, stylesheets etc. All the other cgi/html pages will include the header.cgi.

The only issue I have is that there are multiple <body> tags in the output (html source code).

volatilegx

2:17 pm on May 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Instead of using "open" to pull the main.html, try using LWP::Simple...


use LWP::Simple;
$html = get 'http://www.yourdomain.com/main.html';
print $html;

The downside of this is that it causes extra load for your webserver because it has to make a call for the main.html file through http. The upside is that the server side include in the main.html will be executed :)