zoukankan      html  css  js  c++  java
  • source和sh

    写了一个脚本【xxyScript.sh】,用于判断tomcat是否启动

    #!/bin/bash 
    if [ -z "$(ps -ef | grep tomcat | grep -v 'grep tomcat' | awk -F ' ' '{print $2}'| awk -F ' ' '{print $1}')" ]; then 
        {
            echo "***************************the tomcat has shutdwon , I want to startp it******************************";
            sleep 3; 
            #//home/tomcat/tomA/bin/startup.sh; 
            echo "****************************the tomcat has startp ,and you can look tomA_log for it************************************";
            sleep 3; 
            #tail -f /home/tomcat/tomA/logs/catalina.out;
        }
    fi
    if [ -n "$(ps -ef | grep tomcat | grep -v 'grep tomcat' | awk -F ' ' '{print $2}'| awk -F ' ' '{print $1}')" ]; then 
        {
            echo "*************************the tomcat is startp************************************";
        }
    fi 
    然后使用命令执行:sh /home/tomcat/xxyScript.sh  ,如下图提示
    然后使用命令: source /home/tomcat/xxyScript.sh ,如下图提示,说明了脚本被正常执行了
     
    在找度娘后,看到有人解释:
    原因是source就是直接在本shell下执行,直接读取脚本中命令行并执行,而sh则是新建了一个子shell,然后运行脚本
  • 相关阅读:
    弹出层
    jquery点击切换显示
    jquery使用css类名和id获取元素
    jquery选择器之基本筛选选择器
    jquery选择器之层级选择器
    jquery选择器之全选择器
    jquery选择器之元素选择器
    选择器之类选择器
    jquery选择器之ID选择器
    DOM对象转化为jquery对象
  • 原文地址:https://www.cnblogs.com/xxyBlogs/p/5706997.html
Copyright © 2011-2022 走看看