#!/usr/bin/perl # # Script zur abfrage auf neue Patches bei IBM # # Author: Florian L***** - 15.03.08 # # Usage: ./checkupdate.pl -s(ilent) # ################################################# use strict; # use LWP::UserAgent; # use HTTP::Request; # use WWW::Mechanize; # ##################### ########## # CONFIG # ########## my $receiver = 'florian@***.de'; # Mail Receiver my $proxy = 'http://***:***@***.de:8080/'; # Proxy Authentification my $sendnews = "1"; # Send Mails my $sendnone = "1"; # Send Mails on no new updates my $datfile = ".ibm_update.dat"; # Define the data-file ######################################### ####### DONT EDIT BELOW THIS LINE ####### ######################################### my $silent = $ARGV[0]; my $date = scalar(localtime); my $browser = LWP::UserAgent->new; $browser->timeout(10); $browser->proxy( [ 'http', 'ftp' ], $proxy ) if defined $proxy; $browser->cookie_jar( {} ); open( CHECKFILE, "<", $datfile ); my @checkarray = ; close(CHECKFILE); chomp(@checkarray); my @mailresult; my $gotnew; if ( $sendnone == 1 ) { $gotnew = 1; } else { $gotnew = 0; } open( FILE, ">", $datfile ); if ( $silent eq "-s" ) { } else { print("Checking for new Versions...\n-----------------------------\n"); } my $hmc_request = HTTP::Request->new( 'GET', "http://www14.software.ibm.com/webapp/set2/sas/f/hmc/home.html" ); my $hmc_response = $browser->request($hmc_request); if ( $hmc_response->is_success() ) { my @hmc_site = $hmc_response->content; foreach (@hmc_site) { my $line = $_; if ( $line =~ m/HMC V7 (.+)<\/a>/g ) { if ( $1 eq $checkarray[0] ) { if ( $silent eq "-s" ) { push( @mailresult, "No new HMC Version online: (HMC V7 $checkarray[0])\n\n" ); print FILE "$1\n"; } else { print("No new HMC Version online\n"); print FILE "$1\n"; push( @mailresult, "No new HMC Version online\n" ); } } else { if ( $silent eq "-s" ) { $gotnew = 1; push( @mailresult, "HMC Version: HMC V7 $1\n" ); print FILE "$1\n"; } else { $gotnew = 1; print("HMC Version: HMC V7 $1\n"); print FILE "$1\n"; push( @mailresult, "HMC Version: HMC V7 $1\n" ); } } } } } else { print "ERROR " . $hmc_response->message . "\n"; } my $mech = WWW::Mechanize->new(); $mech->proxy( [ 'http', 'ftp' ], $proxy ); $mech->get( 'http://www-912.ibm.com/eserver/support/fixes/fixcentral/pfixpacks/53'); $mech->submit_form( form_name => 'tlFilter', fields => { tl => 'all', }, button => 'go' ); my @fix_site = $mech->content; foreach (@fix_site) { my $line = $_; if ( $line =~ m/pseriesfixpackinformation\/(.+)\"/g ) { if ( $checkarray[1] eq $1 ) { if ( $silent eq "-s" ) { push( @mailresult, "No new Fixpack online: (Fixpack $checkarray[1])\n\n" ); print FILE "$1\n"; } else { print("No new Fixpack online\n"); print FILE "$1\n"; push( @mailresult, "No new Fixpack online\n" ); } } else { if ( $silent eq "-s" ) { $gotnew = 1; push( @mailresult, "Fixpack: $1\n" ); print FILE "$1\n"; } else { $gotnew = 1; print("Fixpack: $1\n"); print FILE "$1\n"; push( @mailresult, "Fixpack: $1\n" ); } } } } my $vios_request = HTTP::Request->new( 'GET', "http://www14.software.ibm.com/webapp/set2/sas/f/vios/download/home.html" ); my $vios_response = $browser->request($vios_request); if ( $vios_response->is_success() ) { my @vios_site = $vios_response->content; foreach (@vios_site) { my $line = $_; if ( $line =~ m/Fix Pack (.+)<\/a>/g ) { if ( $checkarray[2] eq $1 ) { if ( $silent eq "-s" ) { push( @mailresult, "No new Vios Updates online: (Vios Fixpack $checkarray[2])\n\n" ); print FILE "$1\n"; } else { print("No new Vios Updates online.\n"); print FILE "$1\n"; push( @mailresult, "No new Vios Updates online.\n" ); } } else { if ( $silent eq "-s" ) { $gotnew = 1; push( @mailresult, "Vios Fixpack: $1\n" ); print FILE "$1\n"; } else { $gotnew = 1; print("Vios Fixpack: $1\n"); print FILE "$1\n"; push( @mailresult, "Vios Fixpack: $1\n" ); } } } } } else { print "ERROR " . $vios_response->message . "\n"; } if ( $sendnews == 1 ) { if ( $gotnew == 1 ) { open( SENDMAIL, "|/usr/sbin/sendmail -t" ) || &fehler("Sendmail not Found!\n"); print SENDMAIL <