As usual other people do neater Perl, but here's a try. 

#!/usr/bin/perl -w

# multidiff 1.0
#  Antonomasia <[EMAIL PROTECTED]> 21Apr1998
#  The sort is included here - no need to sort rpm output.
#  Please copy any improvements to me.
#############################################################
#  From: "Mark R. Cervarich" <[EMAIL PROTECTED]>
#  
#  I have 4 machines running RedHat 4.2.  
#  
#  I've done a  'rpm -qa | sort > machinename' on each machine to get a
#  sorted listing of all of the RPMs installed on each machine.  Now, I'd
#  like to send the 4 files to some kind of script that will compare them
#  and show which are the same and which are different.
#  
#  I'm hoping a script like this already exists, if not, I plan on
#  writing one in PERL then letting everyone know about it.  If you have
#  something similar to this that I might be able to modify, let me know
#  before I re-invent the wheel.
#  
#  example (i'm using a ';' to act as a newline to save space in the
#  email):
#  
#  machine1: ash-0.2-8; fstool-2.5-1; gpm-1.10-8; lpr-0.30-0
#  machine2: bash-1.14.7-1; fstool-2.5-1; lpr-0.30-0
#  machine3: ash-0.2-7; fstool-2.5-1; lpr-0.30-0
#  machine4: ash-0.2-8; byacc-1.9-4; gpm-1.10-8
#  
#  ./thecoolscript machine1 machine2 machine3 machine4
#  
#  then the output would be:
#  
#  machine1     machine2        machine3        machine4
#  ---------------------------------------------------------------
#  ash-0.2-8                    ash-0.2-7       ash-0.2-8
#               bash-1.14.7-1
#                                               byacc-1.9-4
#  fstool-2.5-1 fstool-2.5-1    fstool-2.5-1
#  gpm-1.10-8                                   gpm-1.10-8
#  lpr-0.30-0   lpr-0.30-0      lpr-0.30-0
#  
#  also, does anyone have a program/script/perl regex that will separate
#        the package number of a package from the package name?  That
#        would allow me to show different versions of the same package
#        on the same line. (like what I did with ash above)
#  
#  thanks,
#  mark
#  
#  Mark R. Cervarich

@fnames=@ARGV;

while (<>) {
   chomp;
   $tmp=$_;
   s/^([^-][^-]*)-.*/$1/;
   $pack=$_;

   #store package name in package hash
    $packs{$pack}=1;

   #store package version in machine-specific package hash
   $hashname= "msp".$ARGV;
   $$hashname{$pack}=$tmp;
}

foreach $rpm (sort keys (%packs) ) {
     foreach $hash (@fnames) {
         $tmp="msp".$hash;
         if ($$tmp{$rpm}) {printf("%s has %s\n", $hash, $$tmp{$rpm})}
    }
printf("\n");
}

exit(0);

--
##############################################################
# Antonomasia   [EMAIL PROTECTED]                      #
# See http://www.notatla.demon.co.uk/                        #
##############################################################


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
         To unsubscribe: mail [EMAIL PROTECTED] with 
                       "unsubscribe" as the Subject.

Reply via email to