Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Your IP address is: xxx.xxx.xxx.xxx

Posted on 2004-04-12
4
Medium Priority
?
214 Views
Last Modified: 2013-12-25
When a user accesses the web page, how do I display the IP address they are coming from.  I'd like to do this with the CGI.pm PERL module. (and store it in a variable)

TIA
0
Comment
Question by:ramble
[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
  • 2
  • 2
4 Comments
 

Accepted Solution

by:
mannie earned 200 total points
ID: 10805784
Hi

Like this:

$query=new CGI();
print $query->remote_host(); #returns host or IP if host unavail
OR
print $query->http('REMOTE_ADDR') #for IP directly

all http enviroment variables is listed here
http://hoohoo.ncsa.uiuc.edu/cgi/env.html

Best regards
Linus
0
 

Author Comment

by:ramble
ID: 10806547

Thanks, Points awarded.  However, if it's quick...what if you'd want to get the hostname...example, if the IP address resoved to: some.domains.com.  And you wanted that stored in the variable instead of the IP.

Thanks_ramble
0
 

Expert Comment

by:mannie
ID: 10808875
use the print $query->http($string) where $string is any of the http enviroment variables listet on the page in the previous comment. So replace the REMOTE_ADDR with REMOTE_HOST and you'll get the hostname, if that is what you ment with your question?

/Linus
0
 

Author Comment

by:ramble
ID: 10823803

I never tried the ->ADDR string, so, interesting enough, I'm still only receiving the numerical IP address.  (with the remote_host).  But, perhaps it's just not resolving correctly with my "test machine".  Thanks
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

618 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