Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


logging IP and HOST address on the web-server

Posted on 1999-09-28
Medium Priority
Last Modified: 2013-12-25
When a computer comes to my web, I want to make a pupup windows (or print it in the HTML) Saying "Hello computername", in my case (my computer) : "Hello", or like this "Hey IP"

I want to do it with CGI, so the web-server writes a log file of what computers and IP addresses has been to the web !

When computer1 goes to my web the CGI will generate (in the HTML) "Hello IP= you have visited this webpage 5 times"

Getting the IP can be done with SCRIPT, but i only works on Netscape, and is only run on the CLIENT side. The programs shall be run on the web-server side, and shall work on both Netscape and Microsoft IE 3.0 or higher

My web-server can run CGI but not ASP, and the server is running in at LINUX/UNIX system. (if further information on the web-server is needed i'll find out !

I want this to be automatic so that the user, don't have to press a "Ok" buttom, and/or don't have to fill in a form.

How do i do this with SCRIP, ?? or Java ?
PS:I like SCRIPE the most, because all peope don't have Java
Question by:win32
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

Author Comment

ID: 2081119
Upps the last 2 lines of my message shall be ignored !!!

Expert Comment

ID: 2081140

Getting the IP address/Computer name in CGI is very easy, as for the number of times the user has visted, this would best be done with cookies. If you are intrested in looking into CGI to get the details about the user, take a look at:

This will give you a short lesson of CGI Enviroment variables and how to impliment them into your CGI-SCRIPT. I am not the best with cookies in CGI so I cant really help you with that, though I am sure someone else can.

Good Luck

Accepted Solution

clevie earned 390 total points
ID: 2081396

You'll need a combo of CGI and Javascript/cookie.

You'll need to create an index.cgi (if you server supports them) like:


print logfile "$ENV{'REMOTE_HOST'}  ";
print logfile "$ENV{'REMOTE_ADDR'}\n";

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


This program will log the host name and IP and then show the index.html page.  This will take care of the CGI part.  The cookie part is a little too long to explain, but you'll basically need to include in that CGI script code that will place and read the cookie in the client's browser, increment the value by 1, and print it out.

Author Comment

ID: 2082810
Ok where can i go to find a compiler that compiles for a UNIX system

My server only supports CGI under the dir #!/cgi_bin is that a problem ?

Expert Comment

ID: 2082832
Win32, Perl isn't compiled.  Just copy that code to a file called log.cgi for instance.

If your server only allows CGI's in the cgi-bin directory, then you'll need to see if they support exec CGI SSI's and call the CGI from an SSI in your index.html.

Featured Post

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

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…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

722 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