Home » Infrastructure » Unix » use of EOF in scripting
use of EOF in scripting [message #266675] Tue, 11 September 2007 06:54 Go to next message
saharookiedba
Messages: 56
Registered: September 2007
Location: PUNE
Member
Hi
please tell me the reason why we use EOF , when we write sqlplus commands in UNIX Shell Scripting.

sample code:

#!/bin/ksh
#Author : sahadevan
#Assignment 1
#version 1.2

clear
if [ $# -ne 2 ]; then
echo "Invalid Usage: "
echo "Usage assign.sh <spool file name> <oratab file>"
exit 1
fi

if [ -r $2 ]; then
#spoolFile=/usr/users/saha/test/spool1.txt
spoolFile=$1

for sids in `cat /var/opt/oracle/oratab | grep -v \# | grep -v \* |cut -d":" -f 1`
do
export ORACLE_SID=$sids
export ORAENV_ASK=NO
.oraenv
sqlplus "/as sysdba" << EOF
spool $spoolFile
select instance_name from v\$instance;
exit
EOF
done

else
echo "Oratab file given does not exist"
exit 1
fi
Re: use of EOF in scripting [message #266683 is a reply to message #266675] Tue, 11 September 2007 07:11 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
First,
Please read and follow OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format. Use the "Preview Message" button.
Please always post your Oracle version (4 decimals) and OS name and version.

You can use what EOF is just an example. It is just a tag indicating to shell that this is the end of your SQL script.
First "EOF" gives the tag name (EOF), last flags the end of SQLM script. You can replace EOF by what you want.

Regards
Michel
Re: use of EOF in scripting [message #266788 is a reply to message #266683] Tue, 11 September 2007 11:48 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
The feature is called a "here document"
http://en.wikipedia.org/wiki/Here_document
Previous Topic: ORA-04063: view "SYSTEM.V" has errors
Next Topic: records returned from sqlplus command coming in a single row
Goto Forum:
  


Current Time: Thu Mar 28 15:03:39 CDT 2024