Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2009
    Posts
    56

    Exclamation Unanswered: what is the meaning of the following ....

    Hi

    I am having an unix shell script called call.ksh and we are calling oracle packages from script file ...
    having the following code

    ----------------------------------
    sqlplus -s >> $LOGFILE << EOF
    ${TPE_LOGIN_STRING}
    whenever sqlerror exit SQL.SQLCODE
    set serverout on size 1000000 ;
    execute PKG_MINE.CALLME() ;
    commit;
    EOF
    ----------------------------

    CAN U PLEASE HELP ME IN UNDERSTANDING THE CODE

  2. #2
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    248
    Hi,

    the red text you refer to is called the construction of a 'here-document' in UNIX. It consists of a command where between tags the input is specified on the shell commandline. In general:
    Code:
    $ command <<INPUT
    $ ...
    $ ...
    $ INPUT
    Ofcourse this can also be specified in a shellscript. This makes it possible to redirect the output of the command to a logfile.

    Regards,
    Hans
    Last edited by Tyveleyn; 12-06-09 at 06:19.

  3. #3
    Join Date
    Nov 2009
    Posts
    56
    Hi Hans,

    thanks for your reply.

    You mean to say that what ever is their between the lines of code <<EOF ...EOF is going to logfile specified.

    sqlplus -s >> $LOGFILE << EOF
    --
    --
    --
    EOF



    you have specified

    COMMAND ....<< INPUT

    INPUT

    so we can use INPUT also ?

    thanks !!
    Last edited by MIKELALA; 12-06-09 at 10:17.

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Yes, the EOF or INPUT are used to identify where the here-document ends. You can use whichever character sequence you want - as long as the end-marker doesn't occur on a single line within the here-document itself. (It may be part of some other text within the document.) Typically, EOF is used, however.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  5. #5
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    248
    You mean to say that what ever is their between the lines of code <<EOF ...EOF is going to logfile specified.
    No, what I meant to say was that the input the sqlplus program expects is put between the <<WHATEVER ... WHATEVER tags. The output of the sqlplus program is redirected to a logfile but unless the sqlplus program can accept it's input through a pipe it's not possible to both redirect input and output without the here-document construction.

    Regards,
    Hans

  6. #6
    Join Date
    May 2009
    Location
    India
    Posts
    66
    It is as though the contents were coming from a separate file (and so called a "here"file).

    The same word signifies the start abnd end of the here file. It could as well have
    been:
    COMMAND ....<< ANYWORD

    ANYWORD

    instead of

    COMMAND ....<< INPUT

    INPUT
    .

    The end marker for the here file must start at column 1 (annot be indented).

    End

Posting Permissions

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