[Solved] While loop error when add sqlplus command

Hi gurus,

I hit a block when write the script.

I need do while loop, in the loop I have code below.

sqlplus -s abc/abc@abc <<EOF
spool testwhile
select *
from dual;
spool off
exit;
EOF

when I run script with only this code, it works fine.
if I add code as below:

#!/bin/ksh

while :
do
sqlplus -s abc/abc@abc <<EOF
spool testwhile
select *
from dual;
spool off
exit;
EOF
sleep 10
done

I got error:

syntax error at line 5 : `<<' unmatched
 1  #!/bin/ksh

     2  while :
     3  do
     4  sqlplus -s EDSETL/edsetl11@EDR1D <<EOF
     5  spool testwhile
     6  select *
     7  from dual;
     8  spool off
     9  exit;
    10  EOF
    11  sleep 10
    12  done

Anybody can help me this?

Any input is very welcome

thanks in advance.

I suspect that, in putting it in a while loop, you indented the final EOF, which you cannot do. It must be at the beginning of the line.

Thanks for your reply.

since I am very new for unix, would you please give me an example. Thanks

I don't think there is issue with your script, Please make sure you don't have space (white space) after EOF

1 Like

This is good:

cat <<EOF
a
b
c
d
e
EOF

This is bad:

cat <<EOF
a
b
c
d
e
        EOF
1 Like

Thank you very much, this is resolves my problem.

:b: