Link to home
Start Free TrialLog in
Avatar of Matlock
Matlock

asked on

Accessing browsers request

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.
Avatar of icd
icd

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.
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;
ASKER CERTIFIED SOLUTION
Avatar of tiago
tiago

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Matlock

ASKER

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.
"HTTP_HOST" is NOT the remote host!

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

ASKER

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
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.
Avatar of Matlock

ASKER

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