#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Singapore
    Posts
    1
    Rep Power
    0

    Error message but successfull


    Hi

    Are there anyone has problem to run sqlplus using here-document?

    My script are as follows



    #!/bin/sh

    echo "I am about to check number of objects in source schema "
    `$ORACLE_HOME/bin/sqlplus TXX/TXX@HXXX <<HERE
    Set termout off;
    Set linesize 500;
    Set pagesize 0;
    Set verify off;
    Set feedback off;
    exit;
    HERE`

    echo "After cehck number of objects in source, the exit code=" $?



    When i remove the back ticks(before $oracle_home and after here) , it exits directly without executing -echo "After cehck number....."


    When i do not remove the back tiks, i got sqlplus not found error,but the script continues and the output of my echo "After ...." is 127.


    Any one encounter this problem before?
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    7
    Rep Power
    0
    Hi

    In your version,

    a) if you leave the back tiks,
    "<<HERE" is understood as being an argument of sqlplus which does not match the name of an existing file.

    so "<<HERE" is the unknown file

    b) if you remove the back tiks,
    then your "exit;" which is basically supposed to be processed by sqlplus is processed by the shell, that is the reason why it exit totally from the execution process, skipping the echo "After check..."

    -------------------------------------------------

    So I would use a temporary file :

    #!/bin/sh

    echo "I am about to check number of objects in source schema "

    echo "
    Set termout off;
    Set linesize 500;
    Set pagesize 0;
    Set verify off;
    Set feedback off;
    exit; " > temp.sql

    $ORACLE_HOME/bin/sqlplus TXX/TXX@HXXX @temp.sql

    echo "After check number of objects in source, the exit code=" $?

    rm temp.sql
    ------------------

    I hope this help

    - Ctsgnb -

IMN logo majestic logo threadwatch logo seochat tools logo