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 " \t File ' $file ' Doesn't Exists In $PWD Directory \n"
else
echo " \t File ' $file ' Exists In $PWD Direcotry \n"
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 " \t File ' $file ' Doesn't Exists In $PWD Directory \n"
else
echo " \t File ' $file ' Exists In $PWD Direcotry \n"
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

最新文章

  1. 使用代理下载Unity AssetStore上资源的方法
  2. 8.1 消息通信 EventBus
  3. TCP/IP之四书五经[转自2003.12程序员]
  4. Velocity模板引擎语法
  5. Python 基礎 - 字符編碼
  6. Linux就这个范儿 第9章 特种文件系统
  7. angularjs2 学习笔记(二) 组件
  8. Linux下查看文件和文件夹大小的df和du命令
  9. Regsvr32注册ActiveX控件
  10. js中的SetTimeOut
  11. ubuntu 创建eclipse 快捷方式
  12. [汇编语言]-第八章 div指令,伪指令dd,dup
  13. oracle 写入txt
  14. MySQL编译安装错误提示合集
  15. python 操作python
  16. log4j2配置ThresholdFilter,让info文件记录error日志
  17. 微信网页浏览器打开链接后跳转到其他浏览器下载APK文件包
  18. Oracle FM FM09999999 确保8位数字 即使全是0
  19. 又是毕业季I
  20. CSS3实现烟花特效 --web前端

热门文章

  1. Office WORD如何简繁转换
  2. webpack-Targets(构建目标)
  3. Android与设计模式——代理(Proxy)模式
  4. Hashmap在JDK8中的提升
  5. EXCEPT(差集)集合运算
  6. XxPay支付系统-boot版本 使用
  7. 【Java 安全技术探索之路系列:J2SE安全架构】之二:安全管理器
  8. STL_算法_最小值和最大值(min_element、max_element)
  9. Apache Hadoop 和Hadoop生态圈
  10. centos7 配置虚拟交换机(物理交换机truckport设置)(使用brctl)