Oracle Shell script | here document `EOF' unclosed

Hi folks

I m creating script which is give me below error.

[oracle@ scripts]$ ./function.ksh
./function.ksh[17]: here document `EOF' unclosed

Inside the script is

#!/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

#!/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

/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

???????

you can enclose your select statement to generate a file ex: mylist.txt

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 :

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

for i in $LOCATION
do
...
done

Try this:

{ 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
1 Like

Hey dear...

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

:slight_smile: