Tuesday, September 23, 2008

Find Your Version of glibc

This is how you can find the version of glibc installed on your Linux machine:
sharfah@starship:~> rpm -q glibc
glibc-2.3.3-98.73

Thursday, September 04, 2008

Howto: Sign Automated Emails [Unix]

As part of my work, I sometimes have to write scripts which email information out. For example, I have a script which periodically checks disk usage using the df command and emails an alert if greater than 90%. Other scripts query databases using isql or sqlplus and email reports to users. It is very useful to have these emails "signed" by the script, so that you can easily identify which script sent the email.

All of my scripts contain a sign function which simply prints out the hostname and the full name of the script being executed. Here is an example of it in action:

#!/bin/sh

#print out the host and script
sign()
{
    echo
    echo "-- "
    echo `hostname`:`pwd`/$0
}

#create email
SUBJECT=Test
TO=sharfah@xxx.com
echo "This is a test email" > $MAILFILE

#sign it
sign >> $MAILFILE

mailx -s "$SUBJECT" "$TO" < $MAILFILE

Tuesday, September 02, 2008

How to Find Your Solaris Version

If you are developing an application which runs on Solaris, you may need to know which version of Solaris it is, so that you can use the correct JRE build, Sybase libraries etc.

You can do this using the uname command which prints out useful system information. In order to get just the version number (release level) use the -r flag:

sharfah@starship:~> uname -r
5.10
Example:
OS=`uname`
OS_VERSION=`uname -r`

if [ "$OS" = "SunOS" ]
then
 JAVA=/utils/solaris/java_${OS_VERSION}/bin
elif [ "$OS" = "Linux" ]
then
 JAVA=/utils/linux/java/bin
else
 echo "Unknown operating system $OS"
fi
If you want more details on your Solaris version, look at /etc/release.
sharfah@starship:~> cat /etc/release
                        Solaris 10 8/07 s10x_u4wos_12b X86
           Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                            Assembled 16 August 2007