[Tutor] RE: What file is calling the cgi ???

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Sat, 3 Aug 2002 16:17:23 -0700 (PDT)


On Sat, 3 Aug 2002, runsun wrote:

> Last week I asked a question "What file is calling the cgi?" (Tutor
> Digest, vol 1 # 1794, 7/28/02, Topic#3) but got no answer.
>
> I've found a way to get this info so here it is to share:
>
> In the ???.shtml file that is calling the cgi (lets say,
> /testfolder/caller.shtml), instead of using
>
>       <!--#include virtual="/cgi-bin/py/whocalledme.py" -->,
>
> using the following instead:
>
>       <script language=javascript>
>       document.write("<img src=/cgi-bin/py/whocalledme.py?" +
> document.location+ " width=0 height=0>")
>       </script>
>
> This will get the whocalledme.py to run with arguement sys.argv[1] =
> /testfolder/caller.shtml. You then can parse that string for some
> further usage.

Very cool, thanks for the pointer!  That's a cute way of solving things,
by disguising the including of dynamic content as an image GET.


I'm not quite sure how the value of the document.location gets into
sys.argv[1], though.  Doesn't it go into the QUERY_STRING environmental
variable?


Talk to you later!