Created
September 27, 2013 10:29
-
-
Save jonjensen/6726674 to your computer and use it in GitHub Desktop.
Script to compare installed RPMs between two servers using ssh and the rpm command.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
test -n "$TMPDIR" || TMPDIR=/tmp | |
tmpfilebase="$TMPDIR/rpmdb-compare.$$" | |
if test $# -ne 2 | |
then | |
echo "Usage: $0 [user@]server1 [user@]server2" >&2 | |
echo "Special name localhost means this server, without ssh" >&2 | |
exit 1 | |
fi | |
for i in "$@" | |
do | |
tmpfile="$tmpfilebase.$i" | |
if test $i = localhost | |
then | |
rpm -qa --qf '%{NAME}.%{ARCH}\n' | sort > $tmpfile | |
else | |
ssh $i "rpm -qa --qf '%{NAME}.%{ARCH}\n'" | sort > $tmpfile | |
fi | |
done | |
echo "RPMs in $1 only:" | |
comm -23 "$tmpfilebase.$1" "$tmpfilebase.$2" | |
echo | |
echo "RPMs in $2 only:" | |
comm -13 "$tmpfilebase.$1" "$tmpfilebase.$2" | |
rm -f "$tmpfilebase.$1" "$tmpfilebase.$2" |
Thanks for writing this script!
Simple and easy to use for comparing the differences of rpm installed on two systems.
@nomankhn1 save the script as rpmdb, make it executable, then ./rpmdb user@servA user@servB
It will prompt for user@servA pw and user@servB pw, then it will list packages in servA and packages in servB
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Its better if you mention how to use.