• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

logging IP and HOST address on the web-server

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 cbcomputer.bergsoe.dtu.dk", 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
  • 2
  • 2
1 Solution
win32Author Commented:
Upps the last 2 lines of my message shall be ignored !!!

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: http://www.cgi101.com/class/ch3/

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

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.
win32Author Commented:
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 ?
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

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now