Solved

how to return the name of the html page

Posted on 1997-09-01
18
402 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:mickael
Comment Utility

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
Comment Utility
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
Comment Utility

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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 7

Expert Comment

by:faster
Comment Utility
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
Comment Utility
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
Comment Utility
I love answers from gurus like ozo and faster!

Thank You very much
Mickael@adarweb.com
0
 

Author Comment

by:mickael
Comment Utility
I love answers from gurus!

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

Expert Comment

by:ozo
Comment Utility
(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
Comment Utility
Ok, i am getting the picture and should probably be going thru in details of expert-exchange.com
0
 

Author Comment

by:mickael
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now