?
Solved

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

Posted on 2004-04-12
4
Medium Priority
?
211 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

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

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

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

777 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