|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
I would like to grab a visitors IP and hostname (for security purposes) from a HTML form and write it to a file within a perl script.
I've sorted the writing to the file bit but just cannot get the ip or hostname. |
|
#2
|
|||
|
|||
|
$ip = $ENV{'REMOTE_ADDR'};
$n = `nslookup $ip | grep Name`; chop($n); $host = substr($n, rindex($n, " ")+1); if ($host eq "") { $host=$ENV{'REMOTE_ADDR'}; } $ip is the IP address and $host is the Host address. If $ip cannot resolve to $host, $host = $ip so $host won't give you a blank value. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Environmental variables in Perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|