zoukankan      html  css  js  c++  java
  • tomcat下bin文件夹下shell文件分析

       在bin下面有9个sh文件,本文将逐步分析,今天就以version.sh为例

      

    os400=false
    #uname取操作系统名称 如Linux 如果为OS400的操作系统 特殊处理
    case "`uname`" in
    OS400*) os400=true;;
    esac
    
    # resolve links - $0 may be a softlink
    # 解析文件或者符号文件 得到真正文件
    # /home/dragonsuc/bin/version.sh
    # /home/dragonsuc/bin/tm ->/home/dragonsuc/bin/version.sh
    #当以符号连接启动时 找到真正文件/home/dragonsuc/bin/version.sh
    #取得当前执行文件名称
    PRG="$0"
    #判断文件是否是符号文件 文件存在并且是符号文件
    while [ -h "$PRG" ] ; do
      # lr  。。。。 /home/dragonsuc/bin/tm ->/home/dragonsuc/bin/version.sh
      ls=`ls -ld "$PRG"`
      # 注意下面两行中expr精妙用法
      # 得到/home/dragonsuc/bin/version.sh
      link=`expr "$ls" : '.*-> (.*)$'`
      if expr "$link" : '/.*' > /dev/null; then
        PRG="$link"
      else
        PRG=`dirname "$PRG"`/"$link"
      fi
    done
    #得到目录路径 /home/dragonsuc/bin
    PRGDIR=`dirname "$PRG"`
    EXECUTABLE=catalina.sh
    
    # Check that target executable exists
    if $os400; then
      # -x will Only work on the os400 if the files are:
      # 1. owned by the user
      # 2. owned by the PRIMARY group of the user
      # this will not work if the user belongs in secondary groups
      eval
    else
      #测试文件的可执行权限
      if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
        echo "Cannot find $PRGDIR/$EXECUTABLE"
        echo "The file is absent or does not have execute permission"
        echo "This file is needed to run this program"
        exit 1
      fi
    fi
    # 执行文件 $@是传递执行的参数
    exec "$PRGDIR"/"$EXECUTABLE" version "$@"
  • 相关阅读:
    python 数据结构--Set(集合)
    python 数据结构--Dictionary(字典)
    idea使用心得
    SpringBoot(一):构建第一个SpringBoot工程
    springboot服务的一些问题
    maven使用问题总结

    多线程学习三:Thread API,ThreadLocal,synchronized,volatile和Condition
    多线程学习二:线程池 ExecutorService
    多线程学习一:创建多线程的方式
  • 原文地址:https://www.cnblogs.com/dragonsuc/p/4362579.html
Copyright © 2011-2022 走看看