Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2009
    Posts
    22

    Unanswered: sqlplus and shell script

    Hi Folks,

    I have some issues with calling sqlplus form shell script.
    I can run the sqlplus command form the home of the user directory ( i set the alias for sqlplus by editing the .bash_profile of that user ....every thing is fine.
    home:> sqlplus
    I can connect to db
    SQL>

    Now when i try to run the same sqlplus from the a shell script like 1.sh with sqlplus command inside the 1.sh

    it says command not found .

    i tried to edit the even the etc/bashrc file but .... it is same

    So how to fix this so that the sh can get the path variable in linux ( red hat AS 5)

    Do i need to edit define any variables ???

    I think i set the Path correctly , if not it should not work from the home directory i guesss .....correct me if i'm wrong !

    Thanks in advance !

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    show the path, ORACLE_HOME and ORACLE_SID paameters from the unix environment. also when you invoike it in a script, you have to run it differently. See an example below

    Code:
    sqlplus /nolog <<EOF
    connect user/password@sid
    select sysdate from dual;
    exit;
    EOF
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >Now when i try to run the same sqlplus from the a shell script like 1.sh with sqlplus command inside the 1.sh

    prior to the line invoking sqlplus add the following 2 lines

    env | sort -o /tmp/capture.env
    cat /tmp/capture.env
    sqlplus
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  4. #4
    Join Date
    Dec 2009
    Posts
    22
    Quote Originally Posted by anacedent View Post
    >Now when i try to run the same sqlplus from the a shell script like 1.sh with sqlplus command inside the 1.sh

    prior to the line invoking sqlplus add the following 2 lines

    env | sort -o /tmp/capture.env
    cat /tmp/capture.env
    sqlplus
    Thanks for the reply guys ,

    I figured it ...it was the path issues as the sqlplus dir was not included ,
    so i added the sqlplus path and now it works fine.

    Thanks once again guys for taking you time out !

  5. #5
    Join Date
    Jul 2003
    Posts
    2,296
    always call your oracle user $HOME/.profile or $HOME/.bash_profile to setup your environment variables in your shell script.
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  6. #6
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >Now when i try to run the same sqlplus from the a shell script like 1.sh with sqlplus command inside the 1.sh

    post results from following commands so we can see exactly what we are starting with

    env | sort
    cat 1.sh
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •