Unexpected EOF while looking for matching `"'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unexpected EOF while looking for matching `"'
# 1  
Old 04-17-2012
Unexpected EOF while looking for matching `"'

I have a piece of Linux script. It tells me some syntax error. I couldn't find it. Please help me to identify them. Thanks. The code looks like this:


Code:
export ORACLE_SID=MYDB
export SPW=`cat /opt/oracle/scripts/.sys_pw_$ORACLE_SID`
export check_arch=`sqlplus -s << EOF
/ as sysdba
@/opt/oracle/scripts/sql/check_archives.sql
exit;
EOF`

export archive_count=`echo $check_arch | awk -F, '{print $2}'`
export ORACLE_SID=MYDB
export SPW=`cat /opt/oracle/scripts/.sys_pw_$ORACLE_SID`
if [ $check_arch -gt 0 ]; then
echo " Generating the script on MYDB primary instance at `date` " >> $RMAN_LOG_FILE
sqlplus -s << EOF
sys/$SPW as sysdba
@/opt/oracle/scripts/sql/arch_del_$ORACLE_SID_pri.sql
exit;
EOF
else
echo "MYDB Primary Instance does not have Archives to be deleted at this Time." >> $RMAN_LOG_FILE
fi

if [ $check_arch -gt 0 ]; then
echo "Deleting the archive logs on MYDB primary instance at `date` " >> $RMAN_LOG_FILE
export SPW=`cat /opt/oracle/scripts/cron/.sys_pw_$ORACLE_SID`
rman target sys/$SPW@MYDB_primary  log /opt/oracle/logs/arch_del_$ORACLE_SID_pri.log << EOF
@/opt/oracle/scripts/rman/arch_del_$ORACLE_SID_pri.rcv
exit;
EOF
sleep 10
cat /opt/oracle/logs/arch_$ORACLE_SID_pri.log >> $RMAN_LOG_FILE
fi

# Initiate the command string
 
if [ "$CUSER" = "root" ]
then
    su - $ORACLE_USER -c "$CMD_STR" >> $RMAN_LOG_FILE
    RSTAT=$?
else
    /bin/sh -c "$CMD_STR" >> $RMAN_LOG_FILE
    RSTAT=$?
fi
 
# ---------------------------------------------------------------------------
# Log the completion of this script.
# ---------------------------------------------------------------------------

if [ "$RSTAT" = "0" ]
then
   mailx -s "MYDB archivelog backup and deletion completed successfully" developer@ABC.com < $RMAN_LOG_FILE
else
   mailx -s "MYDB archivelog backup and deletion ended in error" developer@ABC.com < $RMAN_LOG_FILE 
 
echo >> $RMAN_LOG_FILE
echo Script $0 >> $RMAN_LOG_FILE
echo ==== $LOGMSG on `date` ==== >> $RMAN_LOG_FILE
echo >> $RMAN_LOG_FILE
 
exit $RSTAT

The error message are:

Code:
line 187: unexpected EOF while looking for matching `"'
line 197: syntax error: unexpected end of file


Last edited by methyl; 04-17-2012 at 08:59 PM.. Reason: please use code tags
# 2  
Old 04-17-2012
Line 3 looks a bit iffy

Quote:
export check_arch=`sqlplus -s << EOF

EOF`
Might be better as:
Code:
export check_arch=`sqlplus -s` << EOF

EOF

The quote at the end of EOF` negates the string as the proper end of the Shell Here document.


Footnote: There are other significant problems with the script, but let's get past the syntax errors first.


/ as sysdba. Shouldn't that be connect / as sysdba ?





Code:
if [ "$CUSER" = "root" ]
then
    su - $ORACLE_USER -c "$CMD_STR" >> $RMAN_LOG_FILE
    RSTAT=$?
else
    /bin/sh -c "$CMD_STR" >> $RMAN_LOG_FILE
    RSTAT=$?
fi

Fundamental: Both of these options start a new Shell. Any subsequent commands in the parent Shell script will never execute.
As it stands not much will happen, because the script never sets a value for $CMD_STR.

Last edited by methyl; 04-17-2012 at 09:30 PM.. Reason: odds and ends as I come across them
# 3  
Old 04-17-2012
Quote:
Originally Posted by duke0001
It tells me some syntax error. I couldn't find it.
There are no syntax errors in the code you posted, the issue is likely in lines before them. Please post the whole script.
# 4  
Old 04-17-2012
@Jlliagre
It's not a syntax error as such but the lack of a proper EOF line messes-up line 3.
# 5  
Old 04-17-2012
Quote:
Originally Posted by methyl
The quote at the end of EOF` negates the string as the proper end of the Shell Here document.
It doesn't actually. The here document doesn't see the backtick.
Here is something demonstrating the syntax is correct (and your suggestion would break it):
Code:
$ cat a
export a=`cat <<EOF
foo
EOF`
echo a=$a
$ ./a
a=foo


Quote:
Fundamental: Both of these options start a new Shell. Any subsequent commands in the parent Shell script will never execute.
They actually will. Both su and sh will return after executing the passed command.
Quote:
As it stands not much will happen, because the script never sets a value for $CMD_STR.
Yes, the script is missing its first part.

Last edited by jlliagre; 04-17-2012 at 09:47 PM..
# 6  
Old 04-18-2012
jlliagre and methyl:

Thanks so much for your advice. Why I didn't post whole script because:

1. the first part of script is working that is to delete archivelog from standby database. The script itself store on standby database server. The part I posted is to delete archivelog on primary database from standby database. This is the one to cause the error.

2. The first part of script is long and contains some sensitive info there. If I need to post them, I have to make many change to combine with company's security policy.

So this is why I only post second part. I will try your suggestion again to see the result.
# 7  
Old 04-18-2012
Thanks jlliagre , I was having a bit of an off-day when I posted that!

Back on topic:
Quote:
@/opt/oracle/scripts/sql/arch_del_$ORACLE_SID_pri.sql

rman target sys/$SPW@MYDB_primary log /opt/oracle/logs/arch_del_$ORACLE_SID_pri
.log << EOF

@/opt/oracle/scripts/rman/arch_del_$ORACLE_SID_pri.rcv

cat /opt/oracle/logs/arch_$ORACLE_SID_pri.log >> $RMAN_LOG_FILE
In each of these lines the substitution of $ORACLE_SID does not work (Shell looks for a variable called $ORACLE_SID_pri ). It should probably be ${ORACLE_SID}_pri .


Quote:
if [ "$RSTAT" = "0" ]
then
mailx -s "MYDB archivelog backup and deletion completed successfully" developer@ABC.com < $RMAN_LOG_FILE
else
mailx -s "MYDB archivelog backup and deletion ended in error" developer@ABC.com < $RMAN_LOG_FILE
There is a fi missing in this if-then-else-fi statement.

As jlliagre deduces, the main problem is in the unposted portion of the script which probably has an errorneous Here Document with a missing or extra quote which is causing the rest of the script to be treated as data (hence no error for the missing "fi").
If your style is consistent you might find it with:
[CODE]grep "EOF" scriptname | sed -n l[/EOF]
The sed is designed to make end-of-line and control characters visble. A common issue is extraneous characters around the Here Document start or end string.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. SCO

"Unexpected EOF within #IF, #ifdef or #ifndef" error when rebuilding / relinking SCO OpenServer 5

Hi, I am a new Unix Guru with very little experience but have the task of P2Ving an old HP Proliant ML370 G5 server to VMware ESX 4.1 or ESXi 5.5. System seems to boots fine but when trying to remove HP software, configure TCP/IP or a driver, I am receiving: -------- ... (7 Replies)
Discussion started by: dj_Italian
7 Replies

2. Shell Programming and Scripting

In awk: unexpected EOF while looking for matching `"'

I am trying to get grep with awk command into variable. But facing error. Could someone pls help. $ cat test_file DEPLOYMENT="abc" # com cluster="bcn" $ grep DEPLOYMENT test_file | awk -F "\"" '{ print $2 }' abc $ a=`echo "grep DEPLOYMENT test_file | awk -F \"\\\"\" '{ print $2 }'"` ;... (6 Replies)
Discussion started by: Manasa Pradeep
6 Replies

3. Shell Programming and Scripting

Unexpected EOF while looking for matching `'' when ran from a cron job

Since cPanel does not support deleting emails older then X amount of days I am using the following on a Cron Job. find -P /home/user/mail/domain/ -mindepth 2 -mtime '+366' -type f -printf '"%p"\n' | grep -v '/Important' | grep -v '/.Important' | xargs -I {} rm -r "{}" Executing it via SSH... (4 Replies)
Discussion started by: tiagom
4 Replies

4. Shell Programming and Scripting

Unexpected EOF while loooking for matching '"

Hi everyone, I'm really new in shell scripting and having trouble resolving this error. Can someone please tell me why I'm getting these errors? Error Message: ./test.sh: line 50: unexpected EOF while looking for matching `'' ./test.sh: line 53: syntax error: unexpected end of file ... (4 Replies)
Discussion started by: simonirang
4 Replies

5. Shell Programming and Scripting

Help to resolve unexpected EOF while looking for matching `"' error

Hi, can someone kindly look into my copy script and figure out why am i getting a "unexpected EOF while looking for matching `"' error message #!/bin/ksh -x cd /home/goldenga/test/flag37 if ; then rm copied.ok cd /home/goldenga/test Upper=`ls -t|grep 'qw*'|cut -d "w" -f 2|head... (4 Replies)
Discussion started by: NDalal007
4 Replies

6. UNIX for Dummies Questions & Answers

unexpected EOF

hello everyone...im having this problem with unexpected EOF with line 85 which is..i cant see whats wrong with it..can any1 plz help me out. read -p "$p1 please enter the number of tries you wish to have:" lifeline function main() { guessnum=0 read -p "Please enter if its sinle player game... (1 Reply)
Discussion started by: Freakhan
1 Replies

7. Shell Programming and Scripting

line 85: unexpected EOF while looking for matching `"'

hello everyone...im having this problem with unexpected EOF with line 85 which is..i cant see whats wrong with it..can any1 plz help me out. read -p "$p1 please enter the number of tries you wish to have:" lifeline function main() { guessnum=0 read -p "Please... (6 Replies)
Discussion started by: Freakhan
6 Replies

8. Shell Programming and Scripting

Unexpected EOF while looking for matching `"'

Hi everyone, I am trying to search for a string in a file that is partly made up of a variable. Here's the code: echo "parentCategory = $parentCategory" echo "parentCategoryFormatted = $parentCategoryFormatted" numUrlsFoundInParentCategory=`grep -c "<Topic r:id=\"Top\/World\/Français\/"... (2 Replies)
Discussion started by: BlueberryPickle
2 Replies

9. Shell Programming and Scripting

"unexpected end of file" when I´m use EOF inside block if

I have a trouble in my script when i use EOF inside block if. If i use EOF whitout block if I don´t have problem. Guys any ideas? Sorry for my terrible English. #!/bin/sh set -xv HOST='ftp.fiction.com.br' USER='fictionuser' PASS='fictionpass' FILE='ftpteste.txt' busca=`find... (4 Replies)
Discussion started by: ricardo.ludwig
4 Replies

10. UNIX for Advanced & Expert Users

unexpected EOF

I ran the following scripts and everytime i get the errot as follows Line 54: unexpected EOF while looking for matching ',' line 57 syntex error unexpected end of file#!/bin/ksh set -x BKUP_DIR=/u03/backups/abu/nightly_backup LOG_FILE=/u03/backups/abu/backup.log ORACLE_HOME=... (9 Replies)
Discussion started by: manna
9 Replies
Login or Register to Ask a Question