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

x
?
Solved

logging IP and HOST address on the web-server

Posted on 1999-09-28
5
Medium Priority
?
212 Views
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 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
Comment
Question by:win32
[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
5 Comments
 

Author Comment

by:win32
ID: 2081119
Upps the last 2 lines of my message shall be ignored !!!
0
 
LVL 1

Expert Comment

by:dhadland
ID: 2081140
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
 
LVL 2

Accepted Solution

by:
clevie earned 390 total points
ID: 2081396
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
 

Author Comment

by:win32
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 ?
0
 
LVL 2

Expert Comment

by:clevie
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.
0

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