小编Pra*_*kar的帖子

使用 shell 脚本设置环境变量 (Linux)

我是 shell 脚本新手。我编写了一个脚本来检查 ORACLE_HOME 和 ORACLE_SID 是否已设置。在其中我调用了其他脚本来设置环境变量。


第一个脚本

while [ 1 -gt 0 ]
do
    echo -e "Please enter path of oracle home directory:\c"
    read DB_HOME
            if [ -d $DB_HOME ]
            then
                    ./oracle_env.sh $DB_HOME "test1"
                    echo "ORACLE_HOME has been set successfully!"
                    status="Y"
                    break
            else
            echo "Path or directory does not exist."
            fi
done
Run Code Online (Sandbox Code Playgroud)

第二个脚本

#This script will set ORACLE_HOME and SID
export ORACLE_HOME=$1
export  ORACLE_SID=$2
Run Code Online (Sandbox Code Playgroud)

当我运行第二个脚本时

./oracle_env.sh /u01/app/oracle test
Run Code Online (Sandbox Code Playgroud)

工作正常。我的意思是,当我跑步时

echo $ORACLE_HOME
Run Code Online (Sandbox Code Playgroud)

它给出了类似的路径

/u01/app/oracle
Run Code Online (Sandbox Code Playgroud)

现在的问题是,当我从第一个脚本运行相同的脚本时,它不起作用。

请帮帮我!

linux shell

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

linux ×1

shell ×1