Issue
I'm trying to run following code in Jenkins pipeline through shell script -
sh'''
export ORACLE_HOME=$ORACLE_HOME
export ORACLE_SID=orcl
cd $ORACLE_HOME/bin
echo "Starting oracle database..."
sqlplus /nolog
conn sys/password as sysdba
shutdown abort
startup
exit success
echo "done"
'''
But this results into an error -
SQL> + conn sys/password as sysdba /home/oracle/jenkins/workspace/Database_Error_Handling@tmp/durable-ca459d3c/script.sh: line 7: conn: command not found
None of the commands are not found however same command works fine from the machine. Can you please help to understand what could be wrong here?
Solution
Try using below script and replace the script which you want to execute in the sqlplus prompt
export ORACLE_HOME=$ORACLE_HOME
export ORACLE_SID=orcl
echo "Starting oracle database..."
$ORACLE_HOME/bin/sqlplus "/nolog" **<< EOF**
select name from v$database;
exit;
-- Replace the above 2 lines which you want to execute it in sqlplus
**EOF**
echo "done"
Answered By - MrGrEEN