1748286 Members
3261 Online
108761 Solutions
New Discussion юеВ

Re: Apache CGI & SSI

 
Rob Daniels
Advisor

Apache CGI & SSI

Hi all,

I created a html layout named mylayout in wich I include another file:



When I load mylayout into my browser, the file testrob.txt is copied into mylayout. This works fine (so I guess my apache config settings are correct).

I run a program inside a cgi script:
#!/bin/sh
echo Content-type: text/html
/mydir/myprog

Inside myprog I display mylayout. However it does NOT include the file testrob.txt when I run the cgi script from my browser.

Anyone have any idea why the include doesnтАЩt work when using a cgi script?

Thank you in advance
Rob

HP Unix 11i
Apache 1.3.19
Mozilla Firefox 2.0.0.10
Microfocus Server Express Cobol
8 REPLIES 8
Torsten.
Acclaimed Contributor

Re: Apache CGI & SSI

I don't know what your scripts do, but I guess about a HTML syntax error in the final data stream.

I would try to run the scripts "standalone" and inspect the HTML syntax.

For example, if you have some tags like begin and end in a wrong order, the result could be very strange or invisible.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Rob Daniels
Advisor

Re: Apache CGI & SSI

Hi Torsten,

thank you for your reply.
The html layout I display in my program is the same layout as the one I directly "get" in my browser. So the difference is:
1. "get" the layout by enter the name in my browser address (include works)
2. "put" the (same) layout into my browser by using a program in my script (executed by enter the script name in my browser). In this case include doesn't work.

Somehow include doesn't work when I display the layout using a program.

There can't be a html error because I use exactly the same layout.

Steven Schweda
Honored Contributor

Re: Apache CGI & SSI

I'll assume that you've used your browser to
inspect the actual HTML, and that you see the
comment ""
in there, rather than the content of
"testrob.txt", as you had hoped. (That I
need to assume anything speaks ill of your
problem description, of course.)

I know nothing, but I can _imagine_ that the
SSI work is done when Apache reads a HTML
source file. CGI script/program output may
get put out directly, and not processed in
the same way as a file which must be read,
processed, and then put out. If my
conjecture is true, then no one is trying to
interpret your "
Steven Schweda
Honored Contributor

Re: Apache CGI & SSI

In a quick skim of the Apache doc for SSI,

http://httpd.apache.org/docs/1.3/howto/ssi.html

nothing conclusive leaped right out at me,
but I'm sticking with my earlier explanation
until something better comes along.

Note that that doc does give an example of
"Including the results of a CGI program",
with which technique you might be able to
achieve the desired result in a somewhat
different way.
Ralph Grothe
Honored Contributor

Re: Apache CGI & SSI

Hi Rob,

I haven't read your whole thread and the others' replies yet.
Also, without delving into server side includes,
I simply suspect that your CGI script violates the server's HTTP response.
The protocol demands a blank line "\r\n" or "\n" between header and body.
The path to myprog in your script follows immediately the HTTP header.

For example, take Perl's CGI to look what a valid HTTP response header should look like
(note the empty line 2 that nl depicted)

$ perl -MCGI=header -le 'print header'|nl
1 Content-Type: text/html; charset=ISO-8859-1
2

Madness, thy name is system administration
Rob Daniels
Advisor

Re: Apache CGI & SSI

Hi Steven & Ralph,

According to someone in the apache forum I have to upgrade to Apache 2.0 and use the apache mod_include module to set up an output filter for SSI.

Thank you for your feedback!
Rob
Steven Schweda
Honored Contributor

Re: Apache CGI & SSI

> [...] I have to upgrade to Apache 2.0 and
> use the apache mod_include module [...]

Presumably, you needed to enable mod_include
in 1.3.x, too, or else no "
Torsten.
Acclaimed Contributor

Re: Apache CGI & SSI

I agree to Ralph, I used in my scripts this line (note this is tcl):

#!/usr/bin/tclsh

puts "Content-type:text/html\n\n"

...

Note the two "\n\n"!
You need to add new lines too.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!