Solved

how to return the name of the html page

Posted on 1997-09-01
18
408 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:mickael
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 7
  • 2
18 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1830024
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
 

Author Comment

by:mickael
ID: 1830025
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
 
LVL 84

Expert Comment

by:ozo
ID: 1830026
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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

Author Comment

by:mickael
ID: 1830027

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


But why it doesn't print test1.html which is the page calling the script?
0
 
LVL 84

Expert Comment

by:ozo
ID: 1830028
Because that's not what my browser put into HTTP_REFERER when it opened the page:-)
(But what's in test1.html?)
0
 

Author Comment

by:mickael
ID: 1830029

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
 
LVL 84

Expert Comment

by:ozo
ID: 1830030
Well, perhaps you could try something like:
<!--#exec cgi="../../cgi-bin/hello.pl?calledfrom=test1.html" -->
 
0
 
LVL 7

Accepted Solution

by:
faster earned 100 total points
ID: 1830031
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
 

Author Comment

by:mickael
ID: 1830032
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
 
LVL 7

Expert Comment

by:faster
ID: 1830033
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
 
LVL 84

Expert Comment

by:ozo
ID: 1830034
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
 

Author Comment

by:mickael
ID: 1830035
I love answers from gurus like ozo and faster!

Thank You very much
Mickael@adarweb.com
0
 

Author Comment

by:mickael
ID: 1830036
I love answers from gurus!

Thank You very much
Mickael@adarweb.com
0
 
LVL 84

Expert Comment

by:ozo
ID: 1830037
(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
 

Author Comment

by:mickael
ID: 1830038
Ok, i am getting the picture and should probably be going thru in details of expert-exchange.com
0
 

Author Comment

by:mickael
ID: 1830039
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
 
LVL 84

Expert Comment

by:ozo
ID: 1830040
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
 

Author Comment

by:mickael
ID: 1830041
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

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question