Forum Moderators: coopster & phranque

Message Too Old, No Replies

SSI within Perl Script

         

squalle

9:15 pm on Feb 16, 2002 (gmt 0)



Is there a way to make an SSI call from within a perl generated page? For example, if I want to use an SSI counter on a perl generated page.

Thanks

amoore

9:39 pm on Feb 16, 2002 (gmt 0)

10+ Year Member



The apache documentation touches on this at [httpd.apache.org]


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.

I have had success with the suggestion, which is to have your CGI call the item that was going to be called through SSI. If it is a process on the server, you can use 'system' or backticks to call it. If it is a URL that should be included, you can use LWP or something like that to fetch it.

Apache 2.0 allegedly allows stacked handlers, so you could parse your CGI output for SSI directives. Doesn't help you much now, though.

volatilegx

6:33 pm on Mar 1, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



not sure if i'm repeating what amoore said, but here's how i'd do it:

instead of displaying output to STDOUT, write it to a temporary .shtml file. Then, use LWP::Simple to "get" the file. This will execute the SSI. You can then further process the data in your perl script, etc.

don't know exactly why anybody'd want to do this, but it is possible.

mjs7231

7:45 am on Mar 5, 2002 (gmt 0)



On a server where I do have perl working, and I want to include another perl script. I usually use the line..

require "UNIX_PATH_TO FILE.cgi"

this will actually run the file where this line is called. However I do not know how t oadd command line arguments. Another note is that it is the UNIX path not the http path. I hope this helps. I could be off on a wild tangent :)

Brett_Tabke

9:29 am on Mar 6, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Volatilegx. That's an excellent tip. I'd never considered that before. And since you can do it on "localhost" if your config is right, it is blindingly fast. (or even faster if you use sockets).

Wow, the ramifications of that are profound. That opens up a whole set of things I've wanted to do before. Auto call other scripts buried in the ssi tmp output...that's cool.

volatilegx

7:51 pm on Mar 11, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hehe, thanks Brett, didn't realize I was doing anything revolutionary :)

I use the LWP::Simple thing all the time for automatic updating of the CGI script I sell... I had never thought of embedding SSI in the text being read till this thread... It could be useful to me, too.

<added>Oh yeah and I didn't even consider the multi-tasking implications of that!!! ***(light bulbs appearing)***</added>

Brett_Tabke

8:06 pm on Mar 11, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I actually think littleman was trying to tell me this little trick last year at one point. He'd mentioned he'd discovered the joys of localhost calling, but at the time I didn't think there was a use for it. ssi activation is something I'll have to watch for as the perfect use.