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

Current OS versions



Greetings, osvers.pl is a little add-on to Infobot which goes to a CGI
(unix.cgi although it will _actually_ go to
www.LucidX.com/cgi-bin/unix.pl) and that CGI will go out to a couple of
other web sites and grab current OS version numbers.  It goes to
official OS web sites such as freebsd.org and redhat.com, although a lot
of OSs weren't added since it would be difficult for the CGI to
understand what to find for the newer versions of the OS since the HTML
on the page is bound to change.  If anyone can add to unix.cgi, please
do and get it out so it can be used.  To get Infobot to work with
osvers.pl place this in src/Extras.pl:

    if ($message =~ /^\s*(cur|current|)( |)(os|unix|operating(
|)system(s|))( |)ver/) {
        my $os = &vers();
        return $os;
    }

So you know you DO NOT need to use unix.cgi, I just put that their since
that's the real program that does most of the work.  The reason I didn't
incorperate it into osvers.pl is because it would really lag the
connection of the bot that is using it.  So if you wish please mess
around with unix.cgi and send it back if you got a neater/better
version.
Ten four,
-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.mandrake.org/en/fdownload.php3"); }
 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 #####
   if($name eq "Mandrake") {
    $res =~ /Linux 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