how to return the name of the html page

Hello,


I was hoping that someone could help me solve the following
problem:

It is regarding the variable script_name, here it is:

When running the hello.pl script (
http://adar.org/pissavy/test1.html )
I am getting the path and name of the script itself. Is
there a way to get ,unstead, the name of the HTML page that
called the script listed there? the script is called with
ssi.


I have tried the $ENV{HTTP_REFERER} but nothing shows up there?

Unix BSDI 3, perl 5, httpd 1.5


I would be grateful if anyone could tell me if this is
possible

Thank You Much

You may reply to: mailto:gtie@club-internet.fr

Mickael Sebban
mickaelAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
Something does show up on the HTTP_REFERER line at http://adar.org/pissavy/test1.html
when it's called with a browser that sets HTTP_REFERER


0
mickaelAuthor Commented:
Hi,

Thanks for your fast response...

I use communicator 4, and here is what I see (nothing ??)

Test exec
HTTP_REFERER:
AUTH_PASS:
CONTENT_LENGTH:
PATH_INFO:
PATH_TRANSLATED:
QUERY_STRING:
REMOTE_ADDR: 194.158.101.104
REMOTE_HOST: ppp-101-104.villette.club-internet.fr
REMOTE_USER:
REQUEST_METHOD: GET
SCRIPT_NAME: /cgi-bin/hello.pl
SERVER_NAME: 192.41.40.72
SERVER_PORT: 80
SERVER_PROTOCOL: HTTP/0.9
SERVER_SOFTWARE: NCSA/1.5.2

0
ozoCommented:
When I make a file containing:

<a href=http://adar.org/pissavy/test1.html>test1.html</A>

and in Netscape 3.02 open file:8630016152.html

and there click on test1.html
I see

Test exec
HTTP_REFERER: file:8630016152.html
AUTH_PASS:
CONTENT_LENGTH:
PATH_INFO:
...

0
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

mickaelAuthor Commented:

Ok, I am slowly learning... Thank You.


But why it doesn't print test1.html which is the page calling the script?
0
ozoCommented:
Because that's not what my browser put into HTTP_REFERER when it opened the page:-)
(But what's in test1.html?)
0
mickaelAuthor Commented:

here is what the HTML looks like...

<html>

<head>
<title>JEUXVIDEO.COM - Les jeux vidéo et l'ETAJV en ligne</title>
</head>

<body bgcolor="#FFFFFF" text="#0000FF" link="#FF0000" vlink="#E10000" topmargin="4" leftmargin="4">

<p align="left">

Test include<br><!--#include file="include.html" --><br><br>
<!--#include file="include.html" -->






<br><br>

Test exec<br>

<!--#exec cgi="../../cgi-bin/hello.pl" -->


</p>
</body>
</html>

I appreciate your looking into my problem...I kind of like that expert-exchange site!
0
ozoCommented:
Well, perhaps you could try something like:
<!--#exec cgi="../../cgi-bin/hello.pl?calledfrom=test1.html" -->
 
0
fasterCommented:
If you write the html pages yourself, it should be very easy:  Just put an hidden field in the html so that your script can know which html is calling the cgi (<INPUT TYPE=HIDDEN NAME=ORGHTML VALUE="test1.html">).  However, if you are concerning that someone else write an html page that use your cgi, then there is no standard way to know the name of the html (HTTP_REFERER may or may not work).  But anyway I don't see there is any reason why you should need that information under such a situation.

Hope this helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mickaelAuthor Commented:
The thing is a number of small scripts where written to use the variable name_scrip for statistical purpose on several hundreed pages (I was told that with Microsoft server that variable returns the page name calling the script and not path and name of the script itself).

If I understand this correctly I need to add the above line to all HTML page to solve my problem?
0
fasterCommented:
Yes, you have to add this to all you html pages, but each page should be different in the value of course.

The http server is nothing but a program running on some computer, it listens to the requests, which are normally generated by browsers (there can be other sources).  The broswer will send the request according to a protocol which is HTTP (1.0 at this moment).  The request wil contain the information so that the server know aht the browser is asking.  Every broswer will have to provide this otherwise it will not be able to do its job.  Besides this, the browser can also send some other information, such the referer, cookie, screen resolution etc.  However, this part is not very standard, different browsers send different information.  That is why some time you can what you want but sometime you can not (the http server will tell you nothing if the browser does not tell it at all).

So that is why you have to provide the information in your html by yourself.  If you have a lot of html files, you can consider writing a simple program to insert the line for you, perl is very good at this.
0
ozoCommented:
You could write a little script which runs for each file *.html,
and changes any occurance of
<!--#exec cgi="../../cgi-bin/hello.pl" -->
therein to
<!--#exec cgi="../../cgi-bin/hello.pl/$file?name_scrip=$file" -->

or adds
<INPUT TYPE=HIDDEN NAME=ORGHTML VALUE="$file">
to any such file

(although I can't quite tell how they're interacting with
values from the REFERER which called test1.html...)


0
mickaelAuthor Commented:
I love answers from gurus like ozo and faster!

Thank You very much
Mickael@adarweb.com
0
mickaelAuthor Commented:
I love answers from gurus!

Thank You very much
Mickael@adarweb.com
0
ozoCommented:
(You probably shouldn't have accepted the answer yet if you had
meant to continue adding comments.
Once the answer is accepted, I have to pay points to come back
to the discussion.)
Please add any furthur comments in a new question,
Thanks.



0
mickaelAuthor Commented:
Ok, i am getting the picture and should probably be going thru in details of expert-exchange.com
0
mickaelAuthor Commented:
Hello,

I have followed your advise and mofified the test1.html page with the following tag  <!--#exec cgi="../../cgi-bin/hello.pl?calledfrom=test1.html" --> but the server now returns the following error:

[an error occurred while processing this directive]


Here is the content of my .htaccess file in this directory:

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*


Options   Indexes FollowSymLinks Includes ExecCGI
AddType   application/x-httpd-cgi .pl
AddType   application/x-httpd-cgi .cgi
AddType   text/x-server-parsed-html .html



<Limit GET>
order deny,allow
deny from all
allow from all
</Limit>
<Limit POST PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName adar.net
AuthUserFile /usr/local/etc/httpd/htdocs/_vti_pvt/service.pwd
AuthGroupFile /usr/local/etc/httpd/htdocs/_vti_pvt/service.grp

Can you suggest any thing?
0
ozoCommented:
The first thing I'd like to suggest is that you start a new qustion,
rather than continuing to comment on this previously-asked-question.
At 5 points per day, I'll only able to come here about every other day.

Have you tried it with
<INPUT TYPE=HIDDEN NAME=ORGHTML VALUE="test1.html">
?
I also see a
Hello world!
after
Test exec
in  http://adar.org/pissavy/test1.html
Are you sure the error's not related to that?
Are there any messages in the server error log?

When I open
http://adar.org/cgi-bin/hello.pl/path?calledfrom=test1.html
I get

Hello world! HTTP_REFERER:
AUTH_PASS:
CONTENT_LENGTH:
PATH_INFO: /path
PATH_TRANSLATED: /usr/local/etc/httpd/htdocs/path
QUERY_STRING: calledfrom=test1.html

But maybe you can't do that inside <!--#exec -->?
I see one suggestion that /path only works when you exec to
an absolute, not a relative pathname, so maybe you could try
 <!--#exec cgi="/cgi-bin/hello.pl...?
But that may depend on your server too

Anyway, please continue this discussion under
Ask_a_New_Question,
rather than here.
 
0
mickaelAuthor Commented:
Hello,


I was unable to pass arguments as per example above because NCSA does not allow them to be passed via SSI.

However,

print "<br>DOCUMENT_NAME: ", $ENV{'DOCUMENT_NAME'};

did the job !!!

www.experts-exchange.com is a great site, I love it...

Sincerely,
Mickael Sebban

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.