Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Solve the problem of exploding "sqlplus: command not found" when executing script

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

As shown in the question, an error like this occurred while executing the script on the Linux server where oracle is installed:

[oracle@hp-db test] $. / getSysdate.sh./getSysdate.sh: line 10: sqlplus: command not found

Problem analysis:

Case 1: the following command is used when using root users to switch to oracle users

[root@hp-db test] # su oracle

This switching of users causes the / home/oracle/.bash_profile file not to be loaded when switching from root users to oracle users, so the environment variables are not loaded

The correct command should be:

[root@hp-db test] # su-oracle

Then test it:

[oracle@hp-db ~] $echo $ORACLE_HOME/home/oracle/app/oracle/product/11.2.0/dbhome_1 [oracle@hp-db ~] $sqlplus "/ as sysdba"

You can find that you can enter the SQL command mode normally.

Case 2: the oracle environment variable in the / home/oracle/.bash_profile file is not set correctly

If the environment variable in this file is set incorrectly, you only need to refer to a correct configuration file to modify it according to the actual situation. The reference file is as follows:

# Oracle Configexport TMP=/tmpexport TMPDIR=$TMPexport ORACLE_HOSTNAME=hp-dbexport ORACLE_BASE=/home/oracle/appexport ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1export ORACLE_SID=yoursidexport ORACLE_TERM=xtermexport ORACLE_UNQNAME=yourunqnameexport PATH=/usr/sbin:$ORACLE_HOME/bin:$PATHexport NLS_LANG= "AMERICAN_AMERICA.AL32UTF8" export EMLOCALHOST=localhost.oracleexport NLS_DATE_FORMAT= "YYYY-MM-DD HH24:MI:SS" export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/libexport CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

PS: the top shell script getSysdate.sh looks like this:

#! / bin/bashVALUE= `sqlplus-S "/ as sysdba"

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report