If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > what is the meaning of the following ....

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-06-09, 01:22
MIKELALA MIKELALA is offline
Registered User
 
Join Date: Nov 2009
Posts: 44
Exclamation 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
Reply With Quote
  #2 (permalink)  
Old 12-06-09, 06:13
Tyveleyn Tyveleyn is offline
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old 12-06-09, 10:11
MIKELALA MIKELALA is offline
Registered User
 
Join Date: Nov 2009
Posts: 44
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.
Reply With Quote
  #4 (permalink)  
Old 12-06-09, 15:58
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,578
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
Reply With Quote
  #5 (permalink)  
Old 12-06-09, 20:04
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Quote:
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
Reply With Quote
  #6 (permalink)  
Old 12-07-09, 01:42
AnanthaP AnanthaP is offline
Registered User
 
Join Date: May 2009
Location: India
Posts: 62
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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On