0403-057 Syntax error at line 17 : `(' is not expected.

Hi,

I am new to shell scripting.i am trying to mail after my backup completed.

Here is my shell script:

if [ -f ${/backup/RMANBKUP/spool/shelltest.log} ]; then
  egrep (ERROR|error|Error|RMAN-) ${/backup/RMANBKUP/spool/shelltest.log} > /dev/null
  if [ $? = 0 ]; then
    RESULT_MSG=WARNING: Errors occurred during the ${ORACLE_SID} Rman backup full.
    mail -s $RESULT_MSG $DBA < ${BACKUP_LOG_FILE}
    touch /backup/RMANBKUP/spool/error.txt
  else
    egrep (Recovery Manager complete) ${/backup/RMANBKUP/spool/shelltest.log} > /dev/null
    if [ $? = 0 ]; then
      RESULT_MSG=${ORACLE_SID} RMAN Backup Full Completed Successfully.
      mail -s $RESULT_MSG $DBA < ${/backup/RMANBKUP/spool/shelltest.log}
    else
      RESULT_MSG=WARNING: ${ORACLE_SID} RMAN Backup full  did not complete.
      echo Backup process was terminated. | mail -s $RESULT_MSG $DBA
    fi
  fi
fi

i got the error:

/backup/RMANBKUP/scripts/shelltest.sh[16]: 0403-057 Syntax error at line 17 : `(' is not expected.

Pls help me get rid of this.

Please always indent the code to let people read it better:

Few suggestions and modifications:

if [ -f "/backup/RMANBKUP/spool/shelltest.log" ]
then
        if egrep -iq "error|RMAN-" "/backup/RMANBKUP/spool/shelltest.log"
        then
                RESULT_MSG="WARNING: Errors occurred during the ${ORACLE_SID} Rman backup full."
                mail -s "$RESULT_MSG" "$DBA" < "$BACKUP_LOG_FILE"
                touch /backup/RMANBKUP/spool/error.txt
        else
                if egrep -q "Recovery Manager complete" "/backup/RMANBKUP/spool/shelltest.log"
                then
                        RESULT_MSG="${ORACLE_SID} RMAN Backup Full Completed Successfully."
                        mail -s "$RESULT_MSG" "$DBA" < "/backup/RMANBKUP/spool/shelltest.log"
                else
                        RESULT_MSG="WARNING: ${ORACLE_SID} RMAN Backup full did not complete."
                        echo "Backup process was terminated." | mail -s "$RESULT_MSG" "$DBA"
                fi
        fi
fi
1 Like

Is that the entire script?
Error says line 17 but not convinced that the error is on the 17th line of what you pasted into the message

thank you buddy its working.and i will post my scripts clearly sure