Sqlplus: Command not found

55,093

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

Share:
55,093

Related videos on Youtube

Aomine Daiki
Author by

Aomine Daiki

Updated on September 18, 2022

Comments

  • Aomine Daiki
    Aomine Daiki almost 2 years

    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 [email protected]:/home/cloud1
    
    #Conection to the Server
    
    ssh [email protected] '/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
    
    • roaima
      roaima about 9 years
      It's not so much that sqlplus doesn't work, it's that the command hasn't been found. Have you actually installed it?
    • Aomine Daiki
      Aomine Daiki about 9 years
      what do you mean ?
    • Aomine Daiki
      Aomine Daiki about 9 years
      sqlplus is in the script serveur, so i tried to execute this script. So the command is actually installed
    • ott--
      ott-- about 9 years
      Does the client,have an oracle client installed?
    • roaima
      roaima about 9 years
      @AomineDaiki if you haven't installed the Oracle client software on the client, you'll not have sqlplus. It's part of the client software package.
    • Aomine Daiki
      Aomine Daiki about 9 years
      @roaima so should i install oracle client, but in this case how can i execute a remote query. the remote execution is the goal of this work
    • roaima
      roaima about 9 years
      @AomineDaiki, oh I see, sorry. You're doing ssh remote_host sqlplus... so you don't need sqlplus installed on the client. Then as suggested by Lambert in their Answer you need to address the ORACLE_HOME and PATH environment variables for the non-interactive ssh session you're using.
    • Aomine Daiki
      Aomine Daiki about 9 years
      @roaima: ssh [email protected] sqlplus / as sysdba is correct?
    • roaima
      roaima about 9 years
      @AomineDaiki, no. You need to configure the environment as described in Lambert's answer to you.
  • Aomine Daiki
    Aomine Daiki about 9 years
    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
  • Lambert
    Lambert about 9 years
    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.
  • Aomine Daiki
    Aomine Daiki about 9 years
    i have changed the oracle environnement but it's also dosen't work
  • Lambert
    Lambert about 9 years
    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.
  • Aomine Daiki
    Aomine Daiki about 9 years
    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
  • Lambert
    Lambert about 9 years
    what does find /u01 -name sqlplus result?
  • Aomine Daiki
    Aomine Daiki about 9 years
    this is the result /u01/app/oracle/product/11.2.0/xe/sqlplus /u01/app/oracle/product/11.2.0/xe/bin/sqlplus
  • Lambert
    Lambert about 9 years
    cloud1@localhost's password: [cloud1@localhost ~]$ sqlplus / as sysdba -bash: sqlplus: command not found [cloud1@localhost ~]$ export ORACLE_BASE=/u01/app/oracle [cloud1@localhost ~]$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe [cloud1@localhost ~]$ export ORACLE_SID=XE [cloud1@localhost ~]$ export PATH=/u01/app/oracle/product/11.2.0/xe/bin:$PATH [cloud1@localhost ~]$ sqlplus SYS/password as sysdba SQL*Plus: Release 11.2.0.2.0 Production on Tue Apr 14 15:34:09 2015 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: <truncated else comment to long>
  • Lambert
    Lambert about 9 years
    Just tried to install a fresh install myself and this is what I get. Unfortunately the comment is not formatted very well.... Please provide your exact output when you have set the environment variables.
  • Aomine Daiki
    Aomine Daiki about 9 years
    the solution is not clear please i need more explication, when i need install this, in the client or the server machine
  • Aomine Daiki
    Aomine Daiki about 9 years
    i do all of this but i don't have any result sqlplus work porperly in the server machine but when i try to run it from the client machine remotly i have command not found
  • Lambert
    Lambert about 9 years
    You need to set (export) the variables in your /home/cloud1/Cloud-Serv file before the sqlplus line. It looks like that your Cloud-Serv line 2 is not right aswell: "echo "Connection is done !" should be: echo 'Connection is done!'
  • Aomine Daiki
    Aomine Daiki about 9 years
    ihave this error ORA-12705: Cannot access NLS data files or invalid environment specified
  • Lambert
    Lambert about 9 years
    So it looks like sqlplus can be found now? Please edit the question and specify which modifications you have made so far and what the exact result is.