日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

shell 调试 2例

發(fā)布時間:2025/3/20 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 shell 调试 2例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

?

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

?

調(diào)試過程:

? 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.


See More: Error : test: argument expected

?

Report ?

?


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

Your script worked for me with no problems:

#!/bin/kshread file if [ -z "$file" ] thenecho " DID NOT ENTER A FILE NAME " elif [ ! -f "$file" ] thenecho " \t File ' $file ' Doesn't Exists In $PWD Directory \n" elseecho " \t File ' $file ' Exists In $PWD Direcotry \n" fiBTW, 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/kshread file if [[ -z $file ]] thenecho " 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"


調(diào)試過程:

crontab 在調(diào)用過程中,只有如下環(huán)境變量
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


轉(zhuǎn)載于:https://www.cnblogs.com/feiyun8616/p/6548713.html

總結(jié)

以上是生活随笔為你收集整理的shell 调试 2例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。