Solved

how to return the name of the html page

Posted on 1997-09-01
18
405 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

803 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