[ back to toc ]

Passing variables via SSI

Date: 2002/04/15 11:21

Q:
Hi,

I'm trying to call a script from within a .shtml page. This first call
works:

<!--#exec cgi="/cgi-bin/makehtml.pl"-->
and returns some html code into the page. But... I want to use that same
script (makehtml.pl) for several pages, which differ by one variable.

For example, here are two pages that I need to call the script:

/archives/questions/index.shtml
/archives/comments/index.shtml

The script behaves differently for each (ie., reads a different file for
questions or comments). I have a variable in the script called $category.
If $category = "questions" it processes one file, and if $category =
"comments" it processes another file.
I'd like to call the script with SSI like:

<!--#exec cgi="/cgi-bin/makehtml.pl?questions-->

or

<!--#exec cgi="/cgi-bin/makehtml.pl?comments-->
Then, when the script executes, I need $category = "questions" or
"comments".

I guess my question is, how do I send this variable via an SSI call, and
how do I get the script to read this input and assign it to $category?

I've looked in a dozen books, and searched the web all night but am not
having any luck. Thanks for any help.

*NAME-DELETED*

A:
Usually SSI scripts can access the same variables as CGI scripts. Thus the
URL part fo9llowing the ? mark should be in $ENV{QUERY_STRING}.

Regards,
Peter

[ back to toc ]