return to first page linux journal archive
keywordscontents

Listing 2. Show IP Perl Script

#!/usr/bin/perl
# 1999: Salmar Consulting Inc.  www.salmar.com
# showppp.pl - show me the ppp connection address
&show_header;
&show_body;
&http_end;
exit();
# Subroutines #
sub get_pppaddr {
   $pppaddr = `/sbin/ifconfig -l ppp0`;
     print "<HR NOSHADE>\n";
     print "<BR><PRE>$pppaddr</PRE><P>\n";
     print "<HR NOSHADE>\n";
}
#
sub show_header {
   print "Content-type: text/html\n\n";
   print "<HTML><HEAD>"
   print "<META HTTP-EQUIV='Refresh'>"
   print "<TITLE>La Connection Address</TITLE>\n";
   print "</HEAD>\n";
}
#
sub show_body {
   print "<BODY BGCOLOR='White'>\n";
   print "<HR noshade>\n";
   print "<H1><font color='Blue'>"
   print "PPP Connection Information</font></H1>\n";
   print "<p><h3>The information you need is the"
   print " number that follows <BR>"
   print "'inet addr:' (4 numbers "
   print "separated by periods).</h3>\n";
   &get_pppaddr;
}
#
sub http_end {
   print "</body>\n";
   print "</html>\n";
}