Server Side Includes
Posted by TedH (TedH), 13 February 2008Hi, I'm trying something I have never done before (again) and so have ended up here.
A script produces 3 items. A database record (FFDB), an HTML file and a small perl script.
The HTML has an SSI calling the small script.
The small script has variables defined when written and references another script with those variables, which in turn accesses the database and produces the correct output. All well and good.
I would like to not have the small script, but instead use an SSI to do the routine.
The small script looks similar to this:
(The following are broken up by hand so's they'll fit on this page without side scroll)
THE SSI I tried out (several variation attempts, but this is as good as any as none of them worked):
I'm either barking up the wrong tree or (more likely) have gotten this wrong, 'cuz I don't know what I'm doing.
Ummm... help please
Posted by admin (Graham Ellis), 13 February 2008It says "unable to include" so I would look at file permissions, setting up of the server (does it allow SSIs), whether the Perl script has the correct #! line at the top of it, and so on.
Two questions / thoughts
a) Whilst things may work this way, it seems quite a convoluted approach to scripting and I wonder if there might be a more conventional way of doing whatever you're looking to achieve
b) Have you tried a step by step approach to getting the elemens of this such as SSI working - just trying a simple one line included file first to get that working in a test program, the building up until you have the whole thing running?
Posted by KevinAD (KevinAD), 13 February 2008First do as Graham has suggested, start easy to make sure the SSI works. Although since you are getting an error back from the SSI call it is evident that the SSI tag is getting parsed and trying to do something, otherwise you would get nothing back at all. Lets look at your SSI tag:
$theid=20080212171505 &crentry -->
If you expect that $datalist and $theid are perl variables, then you are mistaken. Also you can not use a perl function in your SSI tag (&crentry). You are seemingly coding your SSI tag like it is a mini perl program, which of course will not work.
What you can do is pass the variables as query string data to the news.pl program and parse them out and use them int he news.pl script.
<!--#include virtual="c:/aaa/apache/cgi-bin/news/news.pl?datalist=200802 &theid=20080212171505&com=crentry" -->
If you are already familiar with how to parse out the query string data and get it into a perl program then you are ready to go.
Posted by TedH (TedH), 13 February 2008Hi guys,
"seems quite a convoluted approach to scripting and I wonder if there might be a more conventional way of doing whatever you're looking to achieve "
There probably is Graham, I do kinda go at things weird
"You are seemingly coding your SSI tag like it is a mini perl program, which of course will not work. "
In a sense Kevin, that was what I had in mind. I reckoned if and SSI can run like a mini script then I wouldn't need the four liner.
I'll do as suggested by both of you. I'm also trying to figure out the Apache manual page on SSI's, but that'll take some time as there's quite a lot of cross referencing to other stuff that I don't know about.
"query string data" - I'll read up on that too.
Thanks - Ted
Graham - is it me or is the forum script acting up? When I've posted that last couple of times the preview didn't work - just went straight into the post without preview) and I'm not getting the usual email (after ticking the box) - T
Posted by KevinAD (KevinAD), 13 February 2008It is possible to get the query string data from the environment variables or using the CGI module. The CGI module would be safer unless you really know what you are doing, which it is clear you do not at this point, so I recommend you check out the CGI module to get the query string data into your perl program.
Posted by TedH (TedH), 14 February 2008Okay thanks Kevin.
Graham, got email sorted. I had an old domain that I just let go on the address, so changed it.
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho