Solved

Accessing browsers request

Posted on 1997-12-11
8
165 Views
Last Modified: 2013-12-25
Hi there to all, hope you can help,
I'm writing a C program that needs to know Exactly what the User Typed in ie: a URL or IP number. Tryed environment vars PATH_INFO,& PATH_TRANSLATED, these returned NULL, REQUEST_URI not supported by my web server (Zeus), don't know where to go from here, if anyone can help it would be great.
0
Comment
Question by:Matlock
8 Comments
 
LVL 5

Expert Comment

by:icd
ID: 1831618
The only one that might be of help is REQUEST_URI but this does not include the domain name (or the IP).

Try writing a script that will print all environment variables and see if there is one you can use. (I can give you one in perl but not one in C).

If perl is OK then you can get one at:-

http://www.silkwood.co.uk/cgi-scripts/envir.pl

or run it at

http://www.silkwood.co.uk/cgi-bin/envir.pl

Perhaps it will help you.
0
 
LVL 1

Expert Comment

by:dagmar
ID: 1831619
If you're using perl, you really only need this to see all the environment variables Zeus passes to your CGI...

#!/usr/bin/perl

print "Content-type: text/plain\n\n";

foreach $Key (keys %ENV) {
  print "$Key = :$ENV{$Key}:\n";
}

exit;
0
 
LVL 1

Accepted Solution

by:
tiago earned 200 total points
ID: 1831620
use the environment variable "HTTP_HOST".

example in shell script:

<pre>
#!/bin/sh
echo "Content-type: text/plain"
echo
echo "Host:" $HTTP_HOST
</pre>


example in C:
<pre>
#include <stdio.h>
#include <stdlib.h>

main() {
    printf("Content-type: text/plain\n\n");
    printf("Host:%s\n",getenv("HTTP_HOST"));
}
</pre>
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

Author Comment

by:Matlock
ID: 1831621
I'm unable to grade tiago's answer as perhaps it would seem my question was not correctly phrased, I do not want to know who the Remote Host was  but whether they accessed my site by typing its DNS or by its IP number into their browser, and as unlikely as this may seem, it is actually quite possible for my site.
0
 
LVL 1

Expert Comment

by:tiago
ID: 1831622
"HTTP_HOST" is NOT the remote host!

"HTTP_HOST" provides exactly the information you want:
What host the user has typed in the URL.
0
 

Author Comment

by:Matlock
ID: 1831623
Appologies Tiago,
I misunderstood your response to my Question,
however regretably my server does not support this environment
variable. So I just don't have a clue where to go from here.
Hugh
0
 
LVL 1

Expert Comment

by:tiago
ID: 1831624
Try this (if you have not done it yet):

#!/bin/sh
echo "Content-type: text/plain"
echo
set


and take a look at what environment variables your server uses.
0
 

Author Comment

by:Matlock
ID: 1831625
Tiago, thankyou for your help but it would seem that my Web server doesn't support these environment variables.
I'm out of the office now for over a week so please dont think I'm ignoring any response from you.
Matlock                
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Perl script to process a .csv file 18 59
Adding a countdown to HTA 12 95
This script has to run not aganist multiple servers using csv 16 38
-OutVariable to Global 1 18
In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
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 if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 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