So all the good time of day.

My name is Azamat and here is my question. How to determine the ip address in cgi scripts. for example, if you need to connect to a remote computer. And there sits a man who does not know how to define it. And so he went to my page and I kept his ip. Well, something like this.

Can you write the cgi script code or how to determine it by redirecting to another site and that it is recorded on my page (also code) ??

Thank you very much for your attention! I apologize if I misunderstood somewhere. )

    2 answers 2

    print $ENV{'REMOTE_ADDR'} 

    will display the visitor's address

    • #! / usr / bin / perl use CGI qw (: standard); @ ee = ("CHARSET", "HTTP_USER_AGENT", "HTTP_REFERER", "REMOTE_ADDR", "REMOTE_HOST"); $ comment = "Hello !!"; open (ADD_IP, "> file.txt"); foreach $ e (@ee) {print ADD_IP "<b> $ e </ b>: $ ENV {$ e} <br> \ n \ n \ n"; }; close (ADD_IP); print "Content-type: text / html; charset = utf-8 \ n \ n"; foreach $ e (@ee) {print "<b> $ e </ b>: $ ENV {$ e} <br> \ n \ n \ n"; }; Here's the program code can you tell what's wrong? It displays the same address for all users.nsunc.com/~atazhibay/cgi-bin/ip.cgi - Dikaz

    here is the script, try to run and figure it out

     #!/usr/bin/perl # переменные окружения print "Content-type:text/html\n\n"; while (($key, $val) = each %ENV) { print "$key = $val<BR>\n"; }