PDA

View Full Version : SSI and Parameters


meikel
11-29-1998, 10:57 PM
Hi,
today I found a problem that I'm not capable of solving myself. I have successfully set up server-side-includes to call a perl-script and all that works find.
But I want more. I want to pass a parameter to this script as I can do usually via
http://www.meikel.com/cgi-bin/whatever.pl?parameter
But this doesn't work with SSI. I found another way to launch the perl-script via <!--#exec cmd="/big/dom/xmeikel/cgi-bin/whatever.pl parameter"-->
but that didn't work either. Maybe I'm doing something wrong. Is there an easy way to pass one or more parameters to a script?

Greetings from Germany
Meikel Weber
http://www.meikel.com

Terra
11-29-1998, 11:20 PM
Hello Meikel,

Sure, just set an environment variable and have your script pick up on it...

In your SSI...
<!--#set var="testing" value="blah" -->

test.pl
#!/usr/local/bin/perl

print "test", $ENV{'testing'}, "\n";

That should do the trick... http://www.aota.net/ubb//wink.gif

Also you may be able to use (not tested) "whatever.pl/testing"

And look at the PATH_INFO environment variable...

OR

"whatever.pl?testing=blah"

May or may not work... All this is off the top of my head, and not confirmed...

I just usually use the first example above and set my own environment variables, if they are to be static...

--Greetings from someone blowing the SSI dust off my brain--
Terra

[This message has been edited by ccTech (edited 11-29-98).]

Del
11-30-1998, 01:39 AM
I grabbed this off another place's support forums, but it should apply anywhere.


You can't pass a query_string to an 'exec' SSI, but it is possible to pass a query_string to an 'include' SSI.

But on another note, a 'parameter' like [--#exec cmd="cgi-bin/somefile.pl parameter"--] can be used within the script as an argument.

For example,
$variable = ARGV[0];
$variable now has the value of 'parameter'


Hope this helps (just replace the brackets with arrows. I don't remember if this board script eats those things or not hehehe)

Del

meikel
11-30-1998, 03:07 AM
Hi again,

thanks Terra. That set var should do it.

Greetings from someone just using SSI to do nearly nothing
Meikel Weber

meikel
11-30-1998, 03:10 AM
Hi Del,
I don't know why, but this "exec cmd" did not work for me. It just returned nothing. No error-log contained a bit of info on this "nothing happens", so I think that the "set var" approach is a bit easier.

Greetings from me
Meikel Weber

Terra
11-30-1998, 03:28 AM
But on another note, a 'parameter' like [--#exec cmd="cgi-bin/somefile.pl parameter"--] can be used within the script as an argument.

Just a cursory looksie...

Try this:
<!--#include virtual="/big/dom/x????/cgi-bin/somefile.pl parameter" -->

And try again to catch $ARGV[0]...

This may/or/not work, haven't tested it...

I highly recommend the #include virtual, instead of the #exec family... It avoids passing malicious stuff via the shell...

I believe #include uses an internal execv(3) call which bypasses shell variable expansion... Always something worth considering...

Greetings from someone pondering the speculation of it all
Terra

Davis Zhang
09-23-1999, 09:19 AM
I still have this kind problem , anyone help me ?
***test.shtml like this ***
<!--#exec cgi=&quot;/cgi-bin/adv/popupad_test.cgi a001&quot; -->

###perl in here ###
$userid = ARGV[0];
print &quot;Content-type:text/html\n\n&quot;;
print &quot;just test it !! \n\n&quot;;
print &quot;$userid\n\n&quot;;
exit ;