• 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 192.38.218.162 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=192.38.218.162 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
0
win32
Asked:
win32
  • 2
  • 2
1 Solution
 
win32Author Commented:
Upps the last 2 lines of my message shall be ignored !!!
0
 
dhadlandCommented:
Win32

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
0
 
clevieCommented:
Win32,

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

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

#!/usr/local/bin/perl

open(logfile,">>log.txt");
print logfile "$ENV{'REMOTE_HOST'}  ";
print logfile "$ENV{'REMOTE_ADDR'}\n";
}
close(logfile);

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

print<<EOF;
PUT YOUR INDEX.HTML FILE HERE
EOF

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.
0
 
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 ?
0
 
clevieCommented:
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.
0

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