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

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
shell 调试 2例的更多相关文章
- (转)shell调试方法
---恢复内容开始--- 转载:https://www.ibm.com/developerworks/cn/linux/l-cn-shell-debug/ Shell脚本调试技术 曹 羽中2007 年 ...
- shell调试选项
[shell调试选项] 一些常用选项的用法: -n 只读取shell脚本,但不实际执行 -x 进入跟踪方式,显示所执行的每一条命令 -c "string" 从strings中读取命 ...
- 单片机裸机下写一个自己的shell调试器(转)
源: 单片机裸机下写一个自己的shell调试器
- 安卓开发,adb shell 调试sqlite3数据库
安卓开发,adb shell 调试sqlite3数据库 在安卓中创建了sqlite3数据库,想要调试怎么办? 通过adb shell来进行查看. 第一步,将adb加入到系统变量中. 这样就可以在命令行 ...
- 总结一篇shell调试技巧及常见的脚本错误
#常见的调试命令工具 1.使用bash命令参数调试 #使用 [root@game ~]# sh [-xvn] test.sh #参数解释: -x:将执行的脚本内容输出出来,可以看到执行的过程 -n ...
- shell 调试手段总结
对于厌烦了的 print 和 echo,可以尝试点新鲜省力的小手段. 1. 使用 shell 的执行选项 sh 和 bash 常用的执行指令有:-n.-x.-c.-v. 其中: -n 是 noexec ...
- 16 shell调试技术
trap 命令 基本格式: trap command sig1 sig2 ... sigN 有3种信号可以捕获: EXIT : 从函数中退出, 或整个脚本执行完毕 ERR: 当一 ...
- Android漫游记(4)---.so文件动态调试一例
Android平台的动态调试一直以来是个困扰我等Coder的头疼问题,特别是对于本地的动态调试支持.能够说是"弱智"级别的,不知道Google的新版NDK和新出的Android S ...
- shell 调试
感觉编写shell在查找错误的过程中,很让你崩溃,还好shell也提供了一些调试的方式: 语法检查 -n选项做语法检查,而不执行脚本 sh -n script_name.sh 启动 ...
随机推荐
- [经典面试题]在O(1)时间删除链表结点
[题目] 给定链表的头指针和一个结点指针.在O(1)时间删除该结点.链表结点的定义例如以下: struct ListNode { int value; struct ListNode* ...
- Android学习路线(十九)支持不同设备——支持不同(Android)平台版本号
当最新的Android版本号为你的应用提供着非常棒的APIs时.你却要在很多其它的设备更新之前继续支持老的系统版本号.这篇课程怎样在继续支持低版本号的系统的情况下使用新版本号的高级API. Platf ...
- Struts2框架起源
曾经也用过S2SH框架做过几个项目,都不是工作中的,学习WEB开发的时候接触的第一套框架也是S2SH,可是工作之后一直没实用到S2SH 框架进行开发. 感觉曾经用这个框架的时候根本没有深入去了解这个框 ...
- Android 使用图片异步载入框架Universal Image Loader的问题
使用的Jar包 问题: optionsm = new DisplayImageOptions.Builder() .displayer(new RoundedBitmap ...
- base64和图片互转
pom.xml添加 <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec --> <dependen ...
- makefile redefinition or previous definition
operation.h:4: error: redefinition of 'class operation' operation.h:5: error: previous definition of ...
- VS创建Web项目提示配置IISExpress失败
开发服务器VS2013,新建Web项目提示: 打开Web项目提示: 解决方法:控制面板,找到IISExpress,右键 选择修复,解决问题..
- Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content
Content-Type https://tools.ietf.org/html/rfc7231#section-3.1.1.5 https://tools.ietf.org/html/rfc7231 ...
- Linux如何查看进程等常用命令
1.查进程 ps命令查找与进程相关的PID号: ps a 显示现行终端机下的所有程序,包括其他用户的程序. ps -A 显示所有程序. ps c 列出程序时,显示每个程序真正的 ...
- handsontable整理
hansontable简介 hansontable是一个在线类似Excel的表格编辑器,支持丰富的展现和交互,有多样的单元格类型供配置. 核心是由原生JavaScript构建,充分模块化,支持自定义b ...