-1

I have two virtual machines ubuntu, one is a server when I installed oracle 11g express, and the other is a simple client. My goal is to run an sql query remotely from the client machine. So I prepared the query and I sent it to the server. But in the following of the script and after the establishment of the connection to the server, sqlplus dosen't work. And it shows me the following error:

Sqlplus: Command not found

in this work i use this scrpit:

#! /bin/bash

read -p "saisir votre requete: "  req

printf "%s\n" "$req" > t1.txt

sed -e 's/[;,()'\'']/ /g;s/  */ /g' t1.txt > t.txt

`tr -s '[[:blank:]]' '\n' < t.txt `|

  while IFS= read -r word; do

if ! [[ "$word" =~ $(echo ^\($(paste -sd'|' ./req.txt)\)$) ]]; then

var=$(base64 <<< $word)


sed -i -e "s/$word/$var/g" t1.txt
fi

  done

enter code here

scp requete.sql cloud1@1.0.0.1:/home/cloud1

#Conection to the Server

ssh cloud1@1.0.0.1 '/home/cloud1/Cloud-Serv'

and the file Cloud-Serv contains the following code:

#! /bin/bash
"echo "Connection is done !"

sudo service oracle-xe start

sqlplus / as sysdba

exit
  • It's not so much that sqlplus doesn't work, it's that the command hasn't been found. Have you actually installed it? – roaima Apr 10 '15 at 18:25
  • what do you mean ? – Aomine Daiki Apr 10 '15 at 18:30
  • sqlplus is in the script serveur, so i tried to execute this script. So the command is actually installed – Aomine Daiki Apr 10 '15 at 18:33
  • 1
    Is sql plus in the $PATH variable or you could mention the entire path while invoking sqlplus. Btw you might have a typo there with the Sqlplus ( the S should be in lower case ). – rahul Apr 10 '15 at 18:37
  • Does the client,have an oracle client installed? – ott-- Apr 10 '15 at 20:51
6

In most cases, an Oracle instance is running under a special account, say oracle for instance. If you login as that user you need to set the correct environment where $ORACLE_BASE, $ORACLE_HOME and $ORACLE_SID are the most important. Also, the PATH variable can be extended to have $ORACLE_HOME/bin where sqlplus normally resides. Have a look at oraenv to set the correct environment and try to execute sqlplus using $ORACLE_HOME/bin/sqlplus

  • when i try oraenv it shows me: ORACLE_BASE environment variable is not being set since this information is not available for the current user ID cloud1. You can set ORACLE_BASE manually if it is required. How can i edit this parameter – Aomine Daiki Apr 10 '15 at 18:48
  • You can set the parameter ORACLE_BASE using export ORACLE_BASE=/path/to/oracle. The ORACLE_HOME can be set using export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/Db_1 for instance but I suggest you search for a file called oratab where the installed Oracle Home should be listed. Finally you need to set the variable ORACLE_SID using export ORACLE_SID=<DB_SID>. If you need this environment often for user cloud1, then consider to place these lines into the .bashrc or .bash_profile for that user. – Lambert Apr 13 '15 at 6:00
  • i have changed the oracle environnement but it's also dosen't work – Aomine Daiki Apr 13 '15 at 7:52
  • Please update your question with the steps you performed, based on the comments given (the ORACLE environment you have set) and the error message you are now receiving. It might be necessary to start sqlplus with $ORACLE_HOME/bin/sqlplus after you set the environment variables. – Lambert Apr 13 '15 at 7:57
  • in the end of th file ~/.bashrc i have: export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe export ORACLE_SID=XE export NLS_LANG=$ORACLE_HOME/bin/nls_lang.sh` export ORACLE_BASE=/u01/app/oracle export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH export PATH=$ORACLE_HOME/bin:$PATH what change needs to be done – Aomine Daiki Apr 13 '15 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.