从solaris进程获取tomcat安装路径

在SunOS 5.10测试通过。

#!/bin/bash
procinfo=`ps -ef | grep "java" | grep -v "grep"`
if [ $? -eq 0 ]
then
    echo "$procinfo" | while read line
    do
        tomcatuid=`echo $line | awk '{print $1}'`
        tomcatpid=`echo $line | awk '{print $2}'`
        tomcatarg=`pargs $tomcatpid | grep "catalina.home"`
        if [ $? -eq 0 ]
        then
            tomcathome=`echo $tomcatarg | awk -F'=' '{print $2}'`
            tomcatver="$tomcathome/bin/version.sh"
            if [ -f $tomcatver ]
            then
                luser=`logname`
                if [ $luser = $tomcatuid ]
                then
                    $tomcatver
                else
                    su - $tomcatuid -c "$tomcatver"
                fi
            else
                echo "can not find $tomcathome/bin/version.sh"
            fi
        fi
    done
fi


你可能感兴趣的:(Solaris,PS,pargs)