Oracle Shell script | here document `EOF' unclosed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Oracle Shell script | here document `EOF' unclosed
# 1  
Old 10-21-2010
Oracle Shell script | here document `EOF' unclosed

Hi folks

I m creating script which is give me below error.
Code:
[oracle@ scripts]$ ./function.ksh
./function.ksh[17]: here document `EOF' unclosed

Inside the script is
Code:
#!/bin/ksh
export ORACLE_SID=OECDV1
export ORACLE_HOME=/u01/app/oracle/product/10.2.0
export PATH=$ORACLE_HOME/bin:$PATH
echo "sql is starting"
sqlplus -s /nolog <<EOF
set head off pagesize 0 feedback off linesize 200
whenever sqlerror exit 1
conn / as sysdba
COL VALUE FOR A60
select value,name from v\$parameter where value like '%/%' and name like '%dest%' and name not like '%arch%';
EOF>
while read line
do
LOCATION=`echo $line | awk ' { print $1 } '`
done

now if i run like this
Code:
#!/bin/ksh
export ORACLE_SID=OECDV1
export ORACLE_HOME=/u01/app/oracle/product/10.2.0
export PATH=$ORACLE_HOME/bin:$PATH
echo "sql is starting"
sqlplus -s /nolog <<EOF
set head off pagesize 0 feedback off linesize 200
whenever sqlerror exit 1
conn / as sysdba
COL VALUE FOR A60
select value,name from v\$parameter where value like '%/%' and name like '%dest%' and name not like '%arch%';
EOF

if gives me output like this one
Code:
/u01/app/oracle/admin/OECDV/bdump                      background_dump_dest
/u01/app/oracle/admin/OECDV/udump                            user_dump_dest
/u01/app/oracle/admin/OECDV/cdump                            core_dump_dest
/u01/app/oracle/admin/OECDV/audit                            audit_file_dest

Does anybody know how to take this awk 1st column in

while read line from output of sqlplus

???????

Last edited by Scott; 10-21-2010 at 04:28 PM.. Reason: Code tags, please...
# 2  
Old 10-21-2010
you can enclose your select statement to generate a file ex: mylist.txt

Code:
spool /tmp/mylist.txt
select value,name from v\$parameter where value like '%/%' and name like '%dest%' and name not like '%arch%';
spool off

you can they process your file whenever you want

Maybe try this modif :

Code:
LOCATION=`sqlplus -s /nolog <<EOF
set head off pagesize 0 feedback off linesize 200
whenever sqlerror exit 1
conn / as sysdba
COL VALUE FOR A60
select value,name from v\$parameter where value like '%/%' and name like '%dest%' and name not like '%arch%';
EOF
`

and then
Code:
for i in $LOCATION
do
...
done


Last edited by ctsgnb; 10-21-2010 at 04:11 PM..
# 3  
Old 10-21-2010
Try this:
Code:
{ sqlplus -s /nolog <<EOF
set head off pagesize 0 feedback off linesize 200
whenever sqlerror exit 1
conn / as sysdba
COL VALUE FOR A60
select value,name from v\$parameter where value like '%/%' and name like '%dest%' and name not like '%arch%';
EOF
} | 
while read line
do
  echo "$line" | awk ' { print $1 } '
done

This User Gave Thanks to Scrutinizer For This Post:
# 4  
Old 10-21-2010
Hey dear...

Thanks a lot its worked fine as butter....

Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX Shell Script to Remove MongoDB Document-Based on Many inputs

Here I am in a position to write a Unix Shell script(.sh) to remove MongoDB collection documents. I know how to remove based on a condition like below and it works for me. eval 'db.Collection.remove({TimeStamp:{$lte: "'$var'"}}) But I need to change the remove statement based on a new parameter... (1 Reply)
Discussion started by: senthilmadhanT
1 Replies

2. Shell Programming and Scripting

HERE Document in Shell Script

Hi, I have a shell script to install one of our products. It comprises of commands that are specific to the product installation. These commands require user inputs at different stages. To avoid manual feeding of inputs every time, I tried using HERE document. it is like- #! /usr/bin ... (1 Reply)
Discussion started by: nishant.kansal@
1 Replies

3. Shell Programming and Scripting

How to pass Oracle sql script as argument to UNIX shell script?

Hi all, $ echo $SHELL /bin/bash Requirement - How to pass oracle sql script as argument to unix shell script? $ ./output.sh users.sql Below are the shell scripts and the oracle sql file in the same folder. Shell Script $ cat output.sh #!/bin/bash .... (7 Replies)
Discussion started by: a1_win
7 Replies

4. UNIX for Dummies Questions & Answers

multiple if conditions and EOF in a shell script

I want to create an IF condition with multiple condition, in the statement below I want to add OR EOF, can any one please advise how to do. if } != $sample ] && ; then echo ..... fi code tags please (1 Reply)
Discussion started by: analyst
1 Replies

5. Shell Programming and Scripting

How to echo within EOF (here-document)

ssh $USR@$host /bin/bash <<\EOF >> ship-error.txt awk 'BEGIN{f=0} !f { s=$0; sub(/,.+/, "", s); gsub(//, " ", s); t=(systime()-mktime(s)); if(t<=14400) f=1 } f ' /logs/shiperror.log EOF I want to use an echo command within the EOF. Is this possible? something like this: So that it prints... (3 Replies)
Discussion started by: Deepthz
3 Replies

6. UNIX for Dummies Questions & Answers

Need Shell Script for document searching

I need a script that reads only printable characters (no duplicates) from all files in a directory and output them in a text file. (2 Replies)
Discussion started by: l20N1N
2 Replies

7. UNIX for Dummies Questions & Answers

Unclosed EOF (error)

I have a script which throws an error: "here document `EOF' unclosed" The script is: ... main() { RETVAL=`sqlplus -s $ConnectDetails << EOF SET SERVEROUTPUT ON DECLARE errnum NUMBER; errmsg VARCHAR2(1000); BEGIN My_Procedure( errbuf => errmsg, errcode... (2 Replies)
Discussion started by: laiko
2 Replies

8. Shell Programming and Scripting

here document `EOF' unclosed

I am trying to assign the value in variable using below command. exp_stat=`sqlplus -silent USER_NAME/PWD <<EOF set pagesize 0 feedback off verify off heading off echo off select count(*) from TABLE_NAME; exit; EOF` But getting the below error. here... (2 Replies)
Discussion started by: gander_ss
2 Replies

9. Programming

UNIX Shell Script to Create a Document of a PLSQL code.

Hi All, I am supposed to present the documentation for the PLSQL code (PACKAGES, PROCEDURE, FUNCTIONS) of my application. There are sufficient comments in my code. Has anyone written any Shell Script Utility which can parse the PLSQL code and generate some kind of document ( preferrably HTML not... (1 Reply)
Discussion started by: gauravsachan
1 Replies

10. Shell Programming and Scripting

Check EOF in shell script

Hi, I need to check whether one file has EOF or not. There's one daemon in our system, which will pick the files FTPed to us. However, sometimes the daemon picks the file before FTP is finished. So I'm planning to add some checking of EOF on the FTPed files in the shell script. Could... (8 Replies)
Discussion started by: ideazhcy
8 Replies
Login or Register to Ask a Question