获取AIX, LINUX, HP-UX操作系统、DB2,ORACLE,INFORMIX数据库、应用位数信息的脚本

作者: Further
发布时间:2015-07-15 10:31:23

#!/bin/sh
#用于获取当前系统的版本信息
#包括操作系统、数据库、应用位数
#获取操作系统版本
#工具版本 V1.01 2010-09-08 11:29:51
ARG1=$1
DATE=`date +%Y%m%d_%H`
VER="1.01"
echo "===== Get Version Tools ${VER} ${DATE}====="
echo "          OS: "`uname`           
echo "      OS VER: "`uname -a`           
echo "          DB: ${DB}"
echo "  PLATFORM: ${PLATFORM}"
echo "  BASEENV: ${BASEENV}"

#主版本
echo "init VER: "`init |grep BUILD`
echo " init BIT: "`file $HOME/bin/init`
#编译器版本
case `uname` in
AIX)
    COMPILERINFO=`what \`which cc\` |grep "C/C++"|head -n 1`
    MACHINEID=`uname -u`
    WHO="who"
    ;;
Linux)
    COMPILERINFO=`gcc --version|head -n 1`
    MACHINEID=`hostid`
    WHO="who"
    ;;
HP-UX)
    COMPILERINFO=`what \`which cc\`|tail -n 1`
    MACHINEID=`uname -i`
    WHO="who -a"
    ;;
esac
echo "   COMPILER : $COMPILERINFO"
echo "        MID : $MACHINEID"

#数据库客户端版本
case $DB in
informix9)
    DATABASEINFO=`esql -V|head -n 1`
    ;;
oracle9)
    DATABASEINFO="Oracle `proc|head -n 2|tail -n 1`"
    ;;
db2)
    DATABASEINFO=`db2level|grep Informational`
    ;;
esac
echo "  DB CLI VER: $DATABASEINFO"

echo " "
echo "---- host & user ----"
#当前环境
echo "   HOSTNAME : "`hostname`
echo "       USER : "`whoami`
echo "       HOME : ${HOME}"
TTY=`tty |awk '{print substr($1,6,20)}'`     

#tty /dev/pts/9  TTY pts/9

#who

32b3 pts/1        Aug  9 09:11 (192.168.xx.xx)
32b3 pts/8        Aug  9 09:07 (192.168.xx.xx)
32t3 pts/9        Aug  9 09:11 (192.168.xx.xx)


TELNETCLI=`${WHO} |grep ${TTY}|awk '{print $NF}'|sed 's/(//' |sed 's/)//'`
#TELNETCLI=`who -m | cut -d'(' -f2 | cut -d')' -f1`  192.168.XX.XX
TELNETSVR=`netstat -an|grep 23|grep ${TELNETCLI}|head -n 1|awk '{print $4}'`
echo " Telnet CLI : $TELNETCLI"
echo " Telnet SVR : $TELNETSVR"

echo " "
echo " "
echo "---- component verinfo ----"
if [ "${ARG1}" = "-d" ]; then
xxx

else
  echo " SKIP get component verinfo [-d to show it] ..."
fi
echo "=============== END ======================"

补充

awk 'pattern {print ;}'  'NF>0 {print $0}' 打印非空行,$0整行, $1第1列,$NF最后一列print $2,$5;

awk -F: '{print $1,$5}' /etc/passwd  -v 'OFS=XX'修改输出字段的分隔字符。

sed 's/(//'   删除/

来源:http://www.cnblogs.com/qingxia/archive/2012/08/09/2629879.ht

推荐: