Nifty get version script for Linux/Unix

Here’s a simple script I created that grabs all package information from a system, then outputs it to a comma delimited format great for spreadsheets. I grabbed a portion of code from novel’s OSdetech script so this will work on many different Linux distributions

__________

#!/bin/bash
#getversions.sh script by smelendy for umw.
#purpose: grab version info for servers
#OSdetect portion from http://www.novell.com/coolsolutions/feature/11251.html

OS=`uname -s`
REV=`uname -r`
MACH=`uname -m`

GetVersionFromFile()
{
VERSION=`cat $1 | tr “\n” ‘ ‘ | sed s/.*VERSION.*=\ // `
}
if [ "${OS}" = "SunOS" ] ; then
OS=Solaris
ARCH=`uname -p`
OSSTR=”${OS} ${REV}(${ARCH} `uname -v`)”
pkginfo -l |egrep “PKGINST|NAME|VERSION”
elif [ "${OS}" = "Linux" ] ; then
KERNEL=`uname -r`
if [ -f /etc/redhat-release ] ; then
DIST=’RedHat’
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
yum list | awk ‘{print $1, “, version ” $2}’
elif [ -f /etc/debian_version ] ; then
DIST=”Debian `cat /etc/debian_version`”
REV=””
dpkg –list | awk ‘{print $2, “, version ” $3}’
fi
OSSTR=”${OS} ${DIST} ${REV}(${PSUEDONAME} ${KERNEL} ${MACH})”
fi
echo ${OSSTR}

echo Version report of `hostname` on ${OSSTR} system has successfully completed on `date`

____

example how to run

getversions.sh >  textfile.csv

 

More Scripts and other tips coming soon,

 

Posted in Uncategorized | Comments Off

Hello world!

Welcome vistors! This is the first of hopefully many posts to come. This site will provide tales of my many adventures of being a systems administrator here at the University of Mary Washington. Till next time.

Posted in Uncategorized | 1 Comment