#!/usr/local/bin/perl -w use diagnostics; # optional; causes warnings to be explained in greater detail. use strict; # generates compile and run-time errors for certain unsafe constructs. #AGT Tester srvinfo Section print "Backing up old agtsrvinfo.txt...
"; rename ("txtfiles\\srvinfo.txt", "txtfiles\\bac\\srvinfo.bac") || die "Cannot rename agtsrvinfo.txt: $!"; print "Starting AGT Tester hotfixes finder
"; open (PCINFO, "txtfiles\\pcinfo.txt") or die "I could not get at agtpcinfo.txt as input"; open (SRVINFO, ">>txtfiles\\srvinfo.txt") or die "I could not open agtsrvinfo.txt as output"; my $time; $time = localtime(time()); print SRVINFO "$time.---------------------------------------------------------------

"; while () { chomp; my $srv; $srv=$_; print "$srv
"; my $result; $result = `srvinfo -ns \\\\$srv`; my $dump; $dump.="Server Name: $srv
"; $dump.="$result
"; $dump.="
===========================

"; print SRVINFO $dump; $dump=""; } close PCINFO; close SRVINFO; #AGT Tester hotfixes Section print "Backing up old agthotfixes.txt...
"; rename ("hotfixes.txt", "hotfixes.bac") || die "Cannot rename agthotfixes.txt: $!"; open (INPUT, "txtfiles\\srvinfo.txt") or die "I could not open agtsrvinfo.txt"; ($WAIT_NAME, $WAIT_FIX, $WAIT_DRIVE) = (0,1,2); open (OUTPUT, ">>hotfixes.txt") or die "I could not open agthotfixed.txt"; $CUR_STATE = $WAIT_NAME; @FIXES; while() { if($CUR_STATE == $WAIT_NAME && /^Server\ Name\:\ (.+)
/) { print OUTPUT "\#XP_SP1
\#Patches begin here (All)
"; print OUTPUT "\#$1
"; #print OUTPUT "$1"; $CUR_STATE = $WAIT_FIX; } elsif($CUR_STATE == $WAIT_FIX && /^Network\ Error\ (.+)
/) { print OUTPUT " $1"; $CUR_STATE = $WAIT_NAME; } elsif($CUR_STATE == $WAIT_FIX && /^PDC\:\ Error\ (.+)
/) { print OUTPUT " $1"; $CUR_STATE = $WAIT_NAME; } elsif($CUR_STATE == $WAIT_FIX && /^Hotfixes/) { $CUR_STATE = $WAIT_DRIVE; @FIXES=""; } elsif($CUR_STATE == $WAIT_FIX && /^Drive/) { $CUR_STATE = $WAIT_NAME; print OUTPUT "@FIXES"; @FIXES=""; } elsif($CUR_STATE == $WAIT_FIX && /^Network/) { $CUR_STATE = $WAIT_NAME; print OUTPUT "@FIXES"; @FIXES=""; } elsif($CUR_STATE == $WAIT_DRIVE && /^Drive/) { $CUR_STATE = $WAIT_NAME; print OUTPUT "@FIXES"; @FIXES=""; } elsif($CUR_STATE == $WAIT_DRIVE && /^Network/) { $CUR_STATE = $WAIT_NAME; print OUTPUT "@FIXES"; @FIXES=""; } elsif($CUR_STATE == $WAIT_DRIVE && /^Protocols/) { $CUR_STATE = $WAIT_NAME; print OUTPUT "@FIXES"; @FIXES=""; } elsif($CUR_STATE == $WAIT_DRIVE && /\[(.+)\]\:/) { push (@FIXES,"$1
"); } else { # die "INVALID DATA:$_"; } } close INPUT; close OUTPUT;