Passing shell script variable to sql file by reference (bind variable)

Hi All,
I need to import around 50 files every 15 minutes into my target table.
I am using shell script and call procedure to do transform.
I used crontab to do this automate task.
Here is my shell script and sql file:
shell script:
#!/bin/sh
export ORACLE_HOME=/u01/app/oracle/product/9.2.0.4.0
export PATH=$ORACLE_HOME/bin
find /path_rawfile/rawfile -iname raw\*.in > myfile.lst
nfile=1
while [ true ]
do
read iFile #read a line
if [ $? -ne 0 ] #Break if EOF
then
break
fi
#$PATH/sqlplus -s /NOLOG @load_raw.sql $iFile
#/bin/mv -f $iFile /path_rawfile/rawfile/done/
done < myfile.lst
sql file:
connect test/test@evn1
set serveroutput on
variable filename varchar2(50)
begin
:filename := '&1';
exec my_tranform(:filename);
dbms_output.put_line(:filename);
end;
exit;
Even I used bind variable pass to procedure my_transform...
But when i query in sys.v_$sqlarea, the :filename:='&1' still hard parse to sqlarea.
One filename one statement and keep increasing ..
Could everyone help me to change it to bind varialbe(soft parse)?
I would like to incresae my database performance.
Thanks in advance.
Cheer
Message was edited by:
lux

It is the procedure.
It's my fault.
Here is my SQL file again:
conn test/test@evn1
variable filename varchar2(500);
exec :filename:='&1';
exec my_transform(:filename);
exit;
I call this sql file from shell script and call in loop due to i need to load all file one time.
Once i use <<EOF it raise error that's why when I deleted it.
Anyway, what I need to do here is to use bind variable (soft parse).
Since I need to load around 50 files every 15 minutes.
exec :filename:='&1'; this statmet have found hard parse in v_$sqlarea.
I would like to change this to bind varialbe.
Thanks again for your help.

Similar Messages

  • How to pass a result of SQL query to shell script variable

    Hi all,
    I am trying to pass the result of a simple SQL query that only returns a single row into the shell script variable ( This particular SQL is being executed from inside the same shell script).
    I want to use this value of the variable again in the same shell scirpt by opening another SQL plus session.
    I just want to have some values before hand so that I dont have to do multiple joins in the actual SQL to process data.

    Here an example :
    SQL> select empno,ename,deptno from emp;
         EMPNO ENAME          DEPTNO
          7369 SMITH              20
          7499 ALLEN              30
          7521 WARD               30
          7566 JONES              20
          7654 MARTIN             30
          7698 BLAKE              30
          7782 CLARK              10
          7788 SCOTT              20
          7839 KING               10
          7844 TURNER             30
          7876 ADAMS              20
          7900 JAMES              30
          7902 FORD               20
          7934 MILLER             10
    14 rows selected.
    SQL> select * from dept;
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    $ cat my_shell.sh
    ### First query #####
    ENAME_DEPTNO=`sqlplus -s scott/tiger << EOF
    set pages 0
    select ename,deptno from emp where empno=$1;
    exit
    EOF`
    ENAME=`echo $ENAME_DEPTNO | awk '{print $1}'`
    DEPTNO=`echo $ENAME_DEPTNO | awk '{print $2}'`
    echo "Ename         = "$ENAME
    echo "Dept          = "$DEPTNO
    ### Second query #####
    DNAME_LOC=`sqlplus -s scott/tiger << EOF
    set pages 0
    select dname,loc from dept where deptno=$DEPTNO;
    exit
    EOF`
    DNAME=`echo $DNAME_LOC | awk '{print $1}'`
    LOC=`echo $DNAME_LOC | awk '{print $2}'`
    echo "Dept Name     = "$DNAME
    echo "Dept Location = "$LOC
    $ ./my_shell.sh 7902
    Ename         = FORD
    Dept          = 20
    Dept Name     = RESEARCH
    Dept Location = DALLAS
    $                                                                           

  • How to pass arguments to a Unix shell script from PL/SQL?

    We want to run a Linux shell script from PL/SQL (10g). This is our code to run the script only and it works fine.
    dbms_scheduler.create_job
              job_name=>'RUN_LINUX_SCRIPT_' || v_job_name,
              job_type=>'EXECUTABLE',
              job_action=>'/vol0/FileLoadDir/Bank/DATA_FILES/spell_check.sh',
              enabled=>TRUE,
              auto_drop=>FALSE
            );Now we have a requirement to pass 2 arguments to the .sh file. In the .sh file the 2 arguments are defined as $1 and $2.
    I used this method.
    dbms_scheduler.create_job
              job_name=>'RUN_LINUX_SCRIPT_' || v_job_name,
              job_type=>'EXECUTABLE',
              job_action=>'/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2.sh',
              --job_action=>'/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2.sh /vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt /vol0/FileLoadDir/Bank/DATA_FILES/abcdefghij.txt',
              --job_action=>'#!/bin/bash spell /vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt > /vol0/FileLoadDir/Bank/DATA_FILES/abcde.txt',
              number_of_arguments => 2,
              enabled=>FALSE,
              auto_drop=>FALSE,
              comments => 'Testing by Channa'
          DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
            job_name                => 'RUN_LINUX_SCRIPT_' || v_job_name,
            argument_position           => 1,
            argument_value          => '/vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt');
          DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
            job_name                => 'RUN_LINUX_SCRIPT_' || v_job_name,
            argument_position       => 2,
            argument_value          => '/vol0/FileLoadDir/Bank/DATA_FILES/abcdefghij.txt');
          DBMS_SCHEDULER.enable (name => 'RUN_LINUX_SCRIPT_' || v_job_name);But I get an error saying:
    STANDARD_ERROR="/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2.sh: line 4: read: `/vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt': not a valid identifier
    /vol0/FileLoadDir/Bank/DATA_FILES/spell_check2"

    Check this post:
    pass parameter from PL/SQL to Unix "as is"

  • How to prepare for Converting UNIX shell scripts to PL/SQL

    Hi All
    I was said, that i may have to convert a lot of unix shell script to PL/SQL, what are the concepts i need to know to do it efficently,
    what are the options PL/SQL is having to best do that.
    I know the question is little unclear, but I too dont have much inputs about that i'm sorry for that, just its a question of how
    to prepare myself to do it the best way. What are the concepts i have to be familiar with.
    Many Thanks
    MJ

    Just how much work is involved, is hard to say. Many years ago I also wrote (more than once) a complete ETL system using a combination of shell scripts, SQL*Plus and PL/SQL.
    If the PL/SQL code is fairly clean, uses bind variables and not substitution variables, then it should be relatively easy to convert that PL/SQL code in the script to a formal stored procedure in the database.
    There is however bits and pieces that will be difficult to move into the PL/SQL layer as it requires new software - like for example FTP'ing a file from the production server to the ETL server. This can be done using external o/s calls from within PL/SQL. Or, you can install a FTP API library in PL/SQL and FTP that file directly into a CLOB and parse and process the CLOB.
    Think of Oracle as an o/s in its own right. In Oracle we have a mail client, a web browser, IPC methods like pipes and messages queues, cron, file systems, web servers and services, etc. And PL/SQL is the "shell scripting" (times a thousand) language of this Oracle o/s .
    In some cases you will find it fairly easy to map a Unix o/s feature or command to one in Oracle. For example, a Unix wget to fetch a HTML CSV file can easily be replaced in Oracle using a UTL_HTTP call.
    On the other hand, techniques used in Unix like creating a pipe to process data, grep for certain stuff and awk certain tokens for sed to process further... in Oracle this will look and work a lot different and use SQL.

  • Invoke shell script thru pl/sql

    Hi,
    Is it possible to invoke a shell script thru a stored procedure? If possible how do we go about?
    For example,
    We have an application which has the following architecture:
    Front End : Java (web enabled)
    Middle Tier : Java web server 2.0
    Back End : Oracle 8.1.6 on Solaris 2.7.
    Our application needs sql loader to be invoked thru the web. For that there are two approaches.
    1. Call the SQL Loader from front end itself. For this we need to have signed servlets etc., This seems quite complex because our back end and web server resides in two different solaris servers.
    2. Call a stored procedure from front end which in turn calls the shell scripts which can in turn invoke sql loader etc.,
    Do you have better solutions? Any suggestion will be deeply appreciated.
    Thanks,
    Raghu.

    Dear Raghu,
    As per my experience calling external procedures from oracle may cause some moderate-to-severe problems. I suggest an alternative solution which is the following:
    1. Your PL/SQL program calls a C cartridge using ICX. The way it works is you call utl_http.request() or utl_http.request_pieces() if the amount of data to be passed back exceeds 2000 characters.
    2. The C cartridge is basically "Hello WORLD" from Oracle examples. The only change is that you substitute the WRB_printf("Hello World") with popen("script.ksh",...)
    3. This way the C cartridge calls your shell script.
    --PL/SQL
    BEGIN
    utl_http.request(...); --> calls C
    END;
    /* C cartridge
    popen("script.ksh",...) /* --> Calls shell */
    #Shell script1.ksh --> calls sqlldr
    sqlldr ...
    P.S. You gotta have at least Oracle 7.3.4 with the OAS at least 3.02

  • Shell script to call sql script

    Hi All,
    I have a application server and want to make a shell script to call sql script.
    Please let me know how to do the same.
    Regards
    Kumar

    What is the platform you are using and you can give the path of the sql script in your shell script as follows
    1.)first create .sql file...let it is table.sql and has the contents ...
    create table test(x1 varchar2(20),x2 number(4),x3 date)
    exit;
    (2.) write a shell script...like table.sh in vi editor
    Here login is scott/tiger@sid, or apps/apps@sid or whatever you know valid schema
    echo enter the login
    read login
    sqlplus -s $login @table
    (3.)run the script
    $ sh table.sh
    it will create the table in your particular schema

  • Executing Shell Scripts through PL-SQL

    Hi All,
    I am trying to execute a shell script from PL-SQL but I am not getting it right .
    the code i used is as follows
    ----JAVA CLASS ---
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
    import java.io.*;
    public class Host {
    public static void executeCommand(String command) {
    try {
    String[] finalCommand;
    if (isWindows()) {
    finalCommand = new String[4];
    // Use the appropriate path for your windows version.
    finalCommand[0] = "C:\\windows\\system32\\cmd.exe"; // Windows XP/2003
    //finalCommand[0] = "C:\\winnt\\system32\\cmd.exe"; // Windows NT/2000
    finalCommand[1] = "/y";
    finalCommand[2] = "/c";
    finalCommand[3] = command;
    else {
    finalCommand = new String[3];
    finalCommand[0] = "/bin/sh";
    finalCommand[1] = "-c";
    finalCommand[2] = command;
    final Process pr = Runtime.getRuntime().exec(finalCommand);
    pr.waitFor();
    new Thread(new Runnable(){
    public void run() {
    BufferedReader br_in = null;
    try {
    br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    String buff = null;
    while ((buff = br_in.readLine()) != null) {
    System.out.println("Process out :" + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_in.close();
    catch (IOException ioe) {
    System.out.println("Exception caught printing process output.");
    ioe.printStackTrace();
    finally {
    try {
    br_in.close();
    } catch (Exception ex) {}
    }).start();
    new Thread(new Runnable(){
    public void run() {
    BufferedReader br_err = null;
    try {
    br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
    String buff = null;
    while ((buff = br_err.readLine()) != null) {
    System.out.println("Process err :" + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_err.close();
    catch (IOException ioe) {
    System.out.println("Exception caught printing process error.");
    ioe.printStackTrace();
    finally {
    try {
    br_err.close();
    } catch (Exception ex) {}
    }).start();
    catch (Exception ex) {
    System.out.println(ex.getLocalizedMessage());
    public static boolean isWindows() {
    if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
    return true;
    else
    return false;
    ---PROCEDURE TO BE EXECUTED WHICH USES THE ABOVE JAVA CLASS IS ----
    CREATE OR REPLACE PROCEDURE Host_Command (p_command IN VARCHAR2)
    AS LANGUAGE JAVA
    NAME 'Host.executeCommand (java.lang.String)';
    --- THE PERMISSIONS ---
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    --- THE SHELL SCRIPT IS -----
    #!/bin/sh
    # This script removes the carriage returns from the Files having .DAT1 extensions in the /test/ Directory
    # and the sends the single line stream to the new file with the use of 'gawk' command
    # so finaly the files with same primary name but different secondary name are created
    # e.g. file 'test.DAT1' is onverted to 'test.DAT'
    # LOOP on /test/ DIRECTORY FOR SEARCHING FILES HAVING EXTENSION *.DAT1
    for file_name in `ls /test/*.DAT1`
    do
    new_file_name=`echo $file_name | sed 's/DAT1/DAT/'`
    # SEND THE CONTAINTS OF SELECTED FILE IN LOOP AS A CONTINUOUS STREAM TO NEW FILE NAME USING 'gawk' COMMAND
    gawk 'BEGIN { ORS = "''" } { print $0 }' $file_name >> $new_file_name
    # ABOVE LINE WILL CREATE A NEW FILE WITH SAME PRIMARY NAME BUT .DAT AS SECONDARY NAME(EXTENSION)
    # REMOVE THE PRIOR FILE(s) AFTER SUCCESSFUL CALL TO 'gawk'
    # $? returns 0 if the call to gawk command is succesfull
    if test 0 = "$?"
         then
         rm -f $file_name
    fi
    done
    # END LOOP ON /test/ DIRECTORY
    ---THE CALL TO THE PROCEDURE --
    SQL>CALL DBMS_JAVA.SET_OUTPUT(1000000);
    SQL>SET SERVEROUTPUT ON SIZE 1000000
    SQL>exec host('/root/sh ecs_script.sh'); -----------------------------------------------1
    now, the statement 1 is the path of the Shell Script ecs_script.sh
    which uses gawk command and does some operations on some file..
    but when i give the call in Statement 1 its giving error like
    /bin/sh is not a directory
    so i am not getting wHat should I do so that my script "ecs_script.sh" gets executed..
    Please Help.

    The Java proc says:
    > finalCommand[0] = "/bin/sh";
    finalCommand[1] = "-c";
    finalCommand[2] = command;
    You call it as follows:
    SQL>exec host('/root/sh ecs_script.sh');
    The final command will be:
    /bin/sh -c /root/sh ecs_script.sh
    Is this what you intended?

  • Can any one tell me how can i call a shell script from pl/sql

    i like to call shell script from pl/sql procedure.
    can any one suggest how can i do this

    Have you not mastered in asking the same kind of question ?
    First do write a script...
    no one will spoon feed you.
    How can i call a shell script from procedure
    How to call Shell Script from pl/sql block
    -Sk

  • How do you pass shell scripts with cocoa?

    How do you pass shell scripts with cocoa?

    You asked for more detail -- I don't know if this is what you were referring to or not, but here's a little more detail on how to use the system() function if that's what you wanted to know.
    As etresoft mentioned, the system() function can be useful for the kind of thing you are talking about. You will need to write the following statement at the top of your code if you want to use it:
    #include <stdlib.h>
    To use the system() function, simply put the command as you would write it in the Terminal between double quotes between the parenthesis. For example, something as simple as:
    system("ls");
    I don't what the practical use of the above statement would be, but it will run, and that's the general format for the system() function. So just put between the quotes whatever command you want to send.
    Hope there was something helpful here.

  • Call Shell Script from PL-SQL

    Hello All,
    I have been using some well known Java Class and Procedures to execute shell scripts from PL-SQL.
    The different environments I was using before were
    1)
    Operating System (Server) AIX version 5
    Oerating System(Client) Microsoft Windows XP Service Pack 2
    Oracle Database Version Oracle Database 10g Enterprise Edition Release
    10.2.0.1.0
    2)
    Operating System (Server) Red Hat Linux 3.4.5-2
    Oerating System(Client) Microsoft Windows XP Service Pack 2
    Oracle Database Version Oracle Database 10g Enterprise Edition Release
    10.2.0.1.0
    But suddenly I had to drop and recreate the Databases on 1st (AIX) environment
    and
    reinstall the Operating System (Server) Red Hat 3.4.5-2 on IInd environment stated above (which obviously means the reinstallation of Oracle Database there!)
    Now the shell script(through PL-SQL)is executing smoothly for the IInd (Linux) environment[b] but not executing for the Ist (AIX) environment
    and I am not getting how to solve the problem.
    I have given all the permissions to users, shell scripts and all as they were before.
    Can you please help?
    Regards,
    Abhijit.

    Hello All,
    I have been using some well known Java Class and Procedures to execute shell scripts from PL-SQL.
    The different environments I was using before were
    1)
    Operating System (Server) AIX version 5
    Oerating System(Client) Microsoft Windows XP Service Pack 2
    Oracle Database Version Oracle Database 10g Enterprise Edition Release
    10.2.0.1.0
    2)
    Operating System (Server) Red Hat Linux 3.4.5-2
    Oerating System(Client) Microsoft Windows XP Service Pack 2
    Oracle Database Version Oracle Database 10g Enterprise Edition Release
    10.2.0.1.0
    But suddenly I had to drop and recreate the Databases on 1st (AIX) environment
    and
    reinstall the Operating System (Server) Red Hat 3.4.5-2 on IInd environment stated above (which obviously means the reinstallation of Oracle Database there!)
    Now the shell script(through PL-SQL)is executing smoothly for the IInd (Linux) environment[b] but not executing for the Ist (AIX) environment
    and I am not getting how to solve the problem.
    I have given all the permissions to users, shell scripts and all as they were before.
    Can you please help?
    Regards,
    Abhijit.

  • Need  Shell Script  for picking the files

    Hi,
        I want to write a shell script for piking the files in a sequence order (according to filename with time stamp)  from the sorce FTP server ..
                     Requirement is  in the source directory I'm getting files (Jain_1.xml  , Jjain_2.xml, Jain_3.xml .. ect..)  at  present my file adapter is picking all the files at a time  but  i want to pick  one by one... that to first i want to Jain_1.xml  after finish the processing of the file then only my file adapter should  pick the next file ( Jain_2.xml )  .
                  so..  all the forum mates suggest me to write a shell script..  but where  i have to write the s hell script. and where i have to deploy this script.... my Xi is running on UNIX ... so please sugest me  the procedure ...
    Regards
    Jain

    Hi,
    Why dont you use the option EOIO in which files will be picked up in order and will be proccessed in sequence....one after another....
    Regards,
    Sreeni.

  • Passing Shell Script Path into theweb service http:address location

    Hi,
    Can we pass Shell Script Path into the web service <http:address location=shell scriptpathhere />
    can you please suggest on this ?
    Thanks,
    Bharath
    Edited by: user1175364 on Oct 26, 2010 1:57 PM

    Hi,
    Its better you use java to call the shell script and make it a web service and consume it in bpel...u can also try this with java embedding avtivity as well.

  • Returning/passing Java script variable/value to PL/SQL environment

    Hi,
    Can someone give me a sample code about how to return a Java script variable to PLSQL environment?
    for example, I have a javascript function that returns timestamp in milisecond, I then want to write PLSQL code to call this java script function and save its value in a number-typed plsql variable for further calculation, I dont know how the two scripting language communicate.
    Thank you very much
    Binh
    null

    This is quite simple.
    I assume that you are able to define html form side through pl/sql. Suppose your new pl/sql value is v_time then in the procedure that you write include one more statement
    htp.p('<Input type=hidden name="v_time" value="">');
    and also in the form invocation,
    htp.p('<form name=app method=post action="time_handler" onSubmit="return false;">');
    and to the end you must be having a submit
    to it attach a onClick function that calls
    simply our validate function..
    eg htp.p('<Input type=submit value="process"
    onClick="validate();">');
    Include in the head portion
    the following script using htp.p procedure
    function validate()
    app.v_time.value=<calculated value>;
    return app.submit();
    Hope this helps.
    Nat
    null

  • Executing a shell script from pl/sql stored procedure

    Hi,
    I have Oracle 8i on HP-UX.
    I am passing a shell script name as a parameter to a user defined function from a pl/sql stored procedure. This user defined function has insterface to a user defined Java class file in Aurora java virtual machine which is written using runtime class which can execute any OS command or any shell script. I am getting any OS command run successfully, but could not run my own shell script. It's is not getting environment variables of my own, so not getting executed. So please suggest how can get these env variables in my shell script and also suggest other sucurity concerns to be taken into consideration.
    If you have any questions please let me know.
    This is really a very urgent issue.....
    Please help me.
    Thanks
    Srinivasa Rao Kolla

    Your best bet is to use the dbms_pipe builtin package to send the command to the host

  • How to solve this problem in shell script: unexpected end of file

    Hello,
    I need to connect to each databases listed in /etc/oratab and check which database is shutdown(or mounted-only) and which database is opened to accept connection. However, following shell script gives me this error message:
    $>./check_is_db_runing.sh
    ./check_is_db_runing.sh: line 39: syntax error: unexpected end of file
    Could anyone please help me to solve this problem, why the code (line 29 to 32) does not work in the LOOP? It works without the LOOP.
    Thanks in advance!!!
    1 #!/bin/bash
    2
    3 LOGDIR=/data03/oracle/dbscripts
    4 ORATABFILE=/etc/oratab
    5
    6 cat $ORATABFILE | while read LINE
    7 do
    8 case $LINE in
    9 \#*) ;; #comment-line in oratab
    10 *)
    11 ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
    12 if [ "$ORACLE_SID" = '*' ] ; then
    13 # NULL SID - ignore
    14 ORACLE_SID=""
    15 continue
    16 fi
    17
    18 # Proceed only if last field is 'Y'
    19 if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "Y" ] ; then
    20 if [ `echo $ORACLE_SID | cut -b 1` != '+' ]; then
    21
    22 ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
    23 PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc
    24 export ORACLE_SID ORACLE_HOME PATH
    25 LOGFILE=$LOGDIR/check_$ORACLE_SID.log
    26 touch $LOGFILE
    27 #echo $LOGFILE
    28
    29 $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" << EOF > $LOGFILE
    30 select * from global_name;
    31 exit
    32 EOF
    33
    34 fi
    35 fi
    36 ;;
    37 esac
    38 done

    This code works ie. generates logs with sql result - slightly modified to be runable:
    #!/bin/bash
    LOGDIR=/tmp
    ORATABFILE=/etc/oratab
    cat $ORATABFILE | while read LINE
    do
    case $LINE in
    \#*) ;; #comment-line in oratab
    ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
    if \[ -z $ORACLE_SID \] ; then
    # NULL SID - ignore
    ORACLE_SID=""
    continue
    # Proceed only if last field is 'Y'
    else
    ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
    PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc
    export ORACLE_SID ORACLE_HOME PATH
    LOGFILE=$LOGDIR/check_$ORACLE_SID.log
    touch $LOGFILE
    #echo $LOGFILE
    $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" << EOF > $LOGFILE
    select * from global_name;
    exit
    EOF
    fi
    esac
    done

Maybe you are looking for