Unmatched <<

Hi,
I am running sinple ksh script .
From some reason it failed on the following error:
./ogg_status.sh[14]: syntax error at line 16 : `<<' unmatched

Please advise.

#!/usr/bin/ksh
export ORACLE_HOME=/software/oracle/DB10gR2
export LD_LIBRARY_PATH=/software/oracle/DB10gR2/lib:/usr/lib
infoall() {
/goldengate/ggsci<<EOF
info all
exit
EOF
}


$ ./gg_status.sh 
+ export ORACLE_HOME=/software/oracle/DB10gR2
+ export LD_LIBRARY_PATH=/software/oracle/DB10gR2/lib:/usr/lib
./ogg_status.sh[14]: syntax error at line 16 : `<<' unmatched

Is that script posted literally?

The EOF must be at the beginning of the line, not indented.

You run a script named gg_status.sh and show us the first nine lines of an unnamed file. The error message from ksh is saying that there is a problem on line 14 or 16 in a file named ogg_status.sh .

Unless you show us the contents of of the file ogg_status.sh and the command line that invoked ogg_status.sh , there isn't much we can do to help you.

And PLEASE USE CODE tags. The position of the string that ends a here document can be very important when trying to diagnose a shell script. Leaving out the CODE tags hides information that can be crucial in diagnosing a problem like this.

Hi,

Thank you for your feedback.
The problem is happened only when i put the code into a function.

#!/usr/bin/ksh
export ORACLE_HOME=/software/oracle/DB10gR2
export LD_LIBRARY_PATH=/software/oracle/DB10gR2/lib:/usr/lib
cd /goldengate
./ggsci << EOF
info all
exit
EOF
exit

When i am trying to put it inside a function i get the following error :

#!/usr/bin/ksh
set -x
export ORACLE_HOME=/software/oracle/DB10gR2
export LD_LIBRARY_PATH=/software/oracle/DB10gR2/lib:/usr/lib
myinfo() 
{  
cd /goldengate  
./ggsci << EOF  
info all  
exit 
EOF  
}  
extract_stat="`myinfo |grep "PUMP1" | awk '{print $2}'`" 
echo ${extract_stat}

$ ./gg1.sh
+ export ORACLE_HOME=/software/oracle/DB10gR2
+ export LD_LIBRARY_PATH=/software/oracle/DB10gR2/lib:/usr/lib
./gg1.sh[4]: syntax error at line 8 : `<<' unmatched

The string to which word expands terminating a here-document of the form << word has to appear as the only characters on the line terminating the here-document.

In the code you provided in your examples, the EOF appears as a line in the code without the function and correctly terminates the here-document.

In the code you provided for the file gg1.sh , the line that you want to terminate the here-document is EOF . Note the two trailing space characters after EOF . If you remove the trailing spaces, it should work.