zoukankan      html  css  js  c++  java
  • shell 调试 2例

    1.#############

    #!/bin/ksh


      if [ ! -z $TNS_ADMIN ]; then
          export TNS_ADMIN=`dirname $TNS_ADMIN`
            else
                export TNS_ADMIN=$ORACLE_HOME/network/admin
                  fi

                    echo $TNS_ADMIN

    调试过程:

      if [ ! -z $TNS_ADMIN ]; then

    修改为

    if [ ! -z “$TNS_ADMIN” ]; then

    ref doc https://www.computing.net/answers/programming/error-test-argument-expected/18951.html

    Hi,

    When i execute the following script i'm getting test: argument expected error at if [ -z $file ]. Can someone plz advise.

    if [ -z $file ]
    then
    echo " DID NOT ENTER A FILE NAME "
    elif [ ! -f $file ]
    then
    echo " File ' $file ' Doesn't Exists In $PWD Directory "
    else
    echo " File ' $file ' Exists In $PWD Direcotry "
    fi

    Thanks.


     


    #1
    nails May 7, 2009 at 07:02:57

    Your script worked for me with no problems:

    #!/bin/ksh
    
    read file
    if [ -z "$file" ]
    then
       echo " DID NOT ENTER A FILE NAME "
    elif [ ! -f "$file" ]
    then
       echo " 	 File ' $file ' Doesn't Exists In $PWD Directory 
    "
    else
       echo " 	 File ' $file ' Exists In $PWD Direcotry 
    "
    fi
    
    BTW, it's always a good idea to include the shell invocation on line 1 of your script. I'd surround $file with double quotes "$file"
    
    Have you tried the extended test facility - two brackets instead of 1:
    
    
    #!/bin/ksh
    
    read file
    if [[ -z $file ]]
    then
       echo " DID NOT ENTER A FILE NAME "
    elif [[ ! -f $file ]]
    then



    2.#############


    #!/bin/ksh


    set -x


    export ORACLE_BASE=/opt/oracle11g
    export HOME=/home/oracle
    export ORACLE_HOME=/opt/oracle11g/product/11.1.0

    env

      LSNRLOG=`/opt/oracle11g/product/11.1.0/bin/lsnrctl <<EOF
        set current_listener yesinuat
          show trc_directory
            EOF`
                 
        echo "Listener Log File: $LSNRLOG"

      LSNRLOG=`/opt/oracle11g/product/11.1.0/bin/lsnrctl <<EOF | grep trc_directory | awk '{print $6"/"$1".log"}'
      set current_listener yesinuat
      show trc_directory
      EOF`
          echo "Listener Log File: $LSNRLOG"


    调试过程:

    crontab 在调用过程中,只有如下环境变量
    PATH=/usr/bin:/usr/sbin:.
    LOGNAME=oracle
    SHELL=/usr/bin/sh
    HOME=/home/oracle
    PWD=/home/oracle
    TZ=EAT-8


    所以需要在你的shell脚本开始加上
    ##################
    . /etc/profile
    export ORACLE_BASE=/opt/oracle11g
    export HOME=/home/oracle
    export ORACLE_HOME=/opt/oracle11g/product/11.1.0
    ##################

    3。######################

    man test


  • 相关阅读:
    c#时间函数
    .NET中的lock(C#版本)
    关于OpenSmtp邮件标题过长,附件名,用户名出现乱码问题的终及解决Dll文件
    Windbg 用法
    使用OpenXML将数据导入到Excel模板中
    Compiere源码workspace的两个配置文件内容
    我学MEF系列(8):MEF+Unity实现可扩展拦截器
    基于插件架构的简单的Winform框架(上)
    我学Flash/Flex(2):AS3读取XML文件内容
    我学Flash/Flex(1):Action Script3.0基础知识
  • 原文地址:https://www.cnblogs.com/feiyun8616/p/6548713.html
Copyright © 2011-2022 走看看