[thelist] CGI help

Martin Burns martin at easyweb.co.uk
Thu Jun 20 17:11:01 CDT 2002


On Thursday, June 20, 2002, at 05:14  pm, Kevin B. O'Brien wrote:

> I think I know a little more than I did last time. In Martin's
> presentation
> (http://www.evolt.org/article/Breadcrumbs_for_All/17/4428/index.html),
> he
> says to include the script on the page using this line:
>
> <!--#include
> virtual="/cgi-
> bin/cookie_trail.cgi?title=You%20put%20your%20title%20here" -->
>
> When I did that, this is what I found in the server log:
>
> script not found or unable to stat: /home/httpd/cgi-bin/cookie_trail.cgi
>
> The problem is that the path it is looking at for the script is clearly
> wrong. It should be in /home/wwwtest/cgi-bin/, but how to get it to look
> there? I say it should be in that directory because I am working in a
> test
> directory on this before putting anything on the main site.
>
> Well, I tried re-writing the include statement to:
>
> <!--#include
> virtual="/home/wwwtest/cgi-
> bin/cookie_trail.cgi?title=You%20put%20your%20title%20here"
> -->
>
> And this gave me the error message:
>
> File does not exist: /home/www/home/wwwtest/cgi-bin/cookie_trail.cgi
>
> Again, the path is the issue.
>
> Can someone explain to me what is going on here?

Yep. <!--#include virtual is essentially including an existing web page,
and so takes a URL-like path.
<!--#include virtual="/cgi-bin/cookie_trail.cgi"
will give similar results to calling a real URL (or linking to it) like:
<a href="/cgi-bin/cookie_trail.cgi">


So on my site (which doesn't use SSIs any more btw, it's all Zope, but I
left the CGI there for hysterical reasons), you can go to
http://www.easyweb.co.uk/cgi-
bin/cookie_trail2.cgi?title=You%20put%20your%20title%20here
and you get the correct output of the script (remember that it doesn't
have a path to split so will only give the end of it).

The output of the script includes HTTP headers which <!--#include
virtual needs - as it's a real page which would have real headers.

If you want to put a file path there (use pwd to work out what the file
path should be btw), then you'll need to drop out the print
&PrintHeader; line which outputs HTTP headers and bring it in with an
exec call, along the lines of
<!--#exec cmd="perl /home/wwwtest/cgi-
bin/cookie_trail.cgi?title=You%20put%20your%20title%20here" -->

But as the documentation says:
http://httpd.apache.org/docs/mod/mod_include.html
"The use of #include virtual is almost always prefered to using either
#exec cgi or #exec cmd. The former (#include virtual) used the standard
Apache sub-request mechanism to include files or scripts. It is much
better tested and maintained."

Cheers
Martin

_______________________________________________
email: martin at easyweb.co.uk             PGP ID:	0xA835CCCB
	martin at members.evolt.org      snailmail:	30 Shandon Place
   tel:	+44 (0)774 063 9985				Edinburgh,
   url:	http://www.easyweb.co.uk			Scotland




More information about the thelist mailing list