Breadcrumb
Web and Database Development Environment Perl Example
Please go through the HTML Example before doing this example.
Create a sample perl file
Using nano, we can create tutorial.pl:
[username@l-lnx101 username]$ nano tutorial.pl
Copy and paste the following code into your nano screen:
#!/usr/bin/perl -w
use strict;
use Socket;
my $remote_addr = $ENV{'REMOTE_ADDR'};
my $iaddr = inet_aton($remote_addr);
my $remote_host = gethostbyaddr($iaddr,AF_INET);print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>Remote IP</title>\n";
print "</head>\n";
print "<body>\n";
print "<p>\n";
print "REMOTE_ADDR is $remote_addr.<br>\n";
print "Lookup of $remote_addr is <b>$remote_host</b>.\n";
print "</p>\n";
print "</body>\n";
print "</html>\n";
exit;- Save the file and go to http://webdev.cs.uiowa.edu/webdev/COURSEID/USERNAME/tutorial.pl where username is replaced with your hawkid. Unfortunately, this is old code and doesn't cope with IPv6.
The page when viewed on l-lnx100 in the lab looks like:
REMOTE_ADDR is 128.255.44.124
Lookup of 128.255.44.124 is l-lnx100.divms.uiowa.edu