[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

No Subject



Here is the updated CGI which fixed the way it parses the HTML on Linux
Mandrake's site, although you really don't need this CGI to get the
addon working it's good if you want to develop it or use it locally or
something.  The default CGI that osvers.pl, the actual addon you put on
Infobot, is at http://www.LucidX.com/cgi-bin/unix.pl  ... osvers.pl is
still the same so if you already have it you won't need to get this
version but for you who don't have it yet you can get it now.  Over and
out.

-Sam (CommPort5)
#!/usr/bin/perl
use CGI qw(:standard);
use LWP::UserAgent;
my ($x, $ua, $url, $html, $response, $res, $name, $num);
$num = "0";
sub add {
$x .= "$name $1/";
}
do {
 if ($num eq "0") { &con("FreeBSD", "http://www.freebsd.org/releases/"); }
 if ($num eq "1") { &con("Red Hat", "http://www.redhat.com/"); }
 if ($num eq "2") { &con("Slackware", "http://www.slackware.com/"); }
 if ($num eq "3") { &con("Caldera", "http://www.caldera.com/"); }
 if ($num eq "4") { &con("Mandrake", "http://www.linux-mandrake.com/en/"); }
 if ($num eq "5") { &con("OpenBSD", "http://www.openbsd.org/"); }
 if ($num eq "6") { &con("NetBSD", "http://www.netbsd.org/"); }
 if ($num eq "7") { &con("SuSE", "http://www.suse.com/"); }
 sub con {
  $name = $_[0];
  $ua = new LWP::UserAgent;
  $ua->timeout(12);
  $url = $_[1];
  $html = new HTTP::Request('GET',$url);
  $response = $ua->request($html);
  if($response->is_success) {
   $res = $response->content;
   $res =~ s/\n/ /g;
##### FreeBSD #####
   if($name eq "FreeBSD") {
    $res =~ /<B>Release (.*?)<\/B>/;
    &add;
   }
##### Red Hat #####
   if($name eq "Red Hat") {
    $res =~ /<A HREF="\/commerce\/redhatlinux.html">Red Hat Linux (.*?)<\/A>/;
    &add;
   }
##### Slackware #####
   if($name eq "Slackware") {
    $res =~ /<BR>Get (.*?)!<\/A>/;
    &add;
   }
##### Caldera #####
   if($name eq "Caldera") {
    $res =~ /<a href=\/openstore\/openlinux\/ class=nav>OpenLinux (.*?)<\/a><br>/;
    &add;
   }
##### Mandrake old #####
#   if($name eq "Mandrake") {
#    $res =~ /Linux Mandrake (\d\.\d)/;
#    &add;
#   }
##### Mandrake #####
   if($name eq "Mandrake") {
    $res =~ /<\/b> - <b>Mandrake (\d\.\d) /;
    &add;
   }
##### OpenBSD #####
   if($name eq "OpenBSD") {
    $res =~ /The current release is <a href=".*">OpenBSD (.*?)<\/a>/;
    &add;
   }
##### NetBSD #####
   if($name eq "NetBSD") {
    $res =~ /Latest release - (.*?)<\/a>/;
    &add;
   }
##### SuSE #####
   if($name eq "SuSE") {
    $res =~ /<IMG ALIGN=RIGHT ALT="SuSE Linux (.*?) Image"/;
    &add;
   }
##### End of OSs #####
  }
 }
 $num++;
}
while($num ne "10");
$x =~ s/(.*?)\/$/$1/;
print header, start_html("Current OS Versions"), p("Current OS Versions: $x\n");

osvers.pl