FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Show ip adress from perl -script need help

 


svecia
I did a script that shows my ip :
use Socket;
use Sys::Hostname;
my $host = hostname();
my $addr =inet_ntoa(scalar gethostbyname($host || 'localhost'));

It shows my ip adress on the machine connected to internet , but the
machine connectet trough the local network just shows
127.0.0.1
I dont need to do it in perl, I could use shell instead.
manumiglani
Code:
#!/usr/local/bin/perl

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

print "<html><head><title>IP Address Display</title></head><body>\n";
print "<h1>IP Address Display</h1>\n";

$ip = $ENV{'REMOTE_ADDR'};

print "You are using ip address $ip\n";
print "<p>\n";
print "</body></html>\n";


or you could do that in php as well

Code:
$ip=@$REMOTE_ADDR;
echo "<font face='Verdana' size='3'><b>IP Address= $ip</b>";
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.