Error for "continue" keyword in Linux script.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error for "continue" keyword in Linux script.
# 1  
Old 12-07-2011
Error for "continue" keyword in Linux script.

Hi All

I have a function in a linux script like this

Code:
clean_up()
{
        db2 -x "UPDATE ${DB_SCHEMA_NAME}.ETL_DAILY SET ETL_STATUS = 'SUCCESSFUL' WHERE PROCESS_DATE = '${INT_RUN_DATE}' AND BATCH_NO = ${CM_BATCH} AND APP_ID = ${APP_ID} AND APP_VERSION = '${APP_VERSION}'" > ${TMPOUT}
        [ `grep SQLSTATE ${TMPOUT} | wc -l` -gt 0 ] && echo `date`": Failed:       ${DB_SCHEMA_NAME}.ETL_DAILY: UPDATE failed" && fclean_up "${DB_SCHEMA_NAME}.ETL_DAILY: UPDATE failed" && return 0
        echo `date`": Info:         `basename $0`: Completed Successfully !" && echo `date`": Info:         `basename $0`: Completed Successfully !" >> ${EXECUTION_LOG}
        [ -f $CM_dsload_prog_ind ] && rm $CM_dsload_prog_ind || continue
        [ -f $DIMJOBLST ] && rm $DIMJOBLST || continue
        [ -f $DIMJOBLST_COMMON ] && rm $DIMJOBLST_COMMON || continue
        [ -f $DIMJOBLST_ENABLED ] && rm $DIMJOBLST_ENABLED || continue
}

But at this function its throwing an error like this
Code:
  continue: only meaningful in a `for', `while', or `until' loop

Could you all please help me why this error is occuring and what would be the impact if i remove the continue keywords from this functions.

Thanks
# 2  
Old 12-07-2011
The error message says it all. Condition testing is not looping. Continue or break can be used only in loops. There will be no impact if you remove continue. Its superfluous and will only throw exceptions like what you saw.
# 3  
Old 12-07-2011
Can someone please help me on this.
# 4  
Old 12-07-2011
This should work, though untested:
Code:
 clean_up()
{
        db2 -x "UPDATE ${DB_SCHEMA_NAME}.ETL_DAILY SET ETL_STATUS = 'SUCCESSFUL' WHERE PROCESS_DATE = '${INT_RUN_DATE}' AND BATCH_NO = ${CM_BATCH} AND APP_ID = ${APP_ID} AND APP_VERSION = '${APP_VERSION}'" > ${TMPOUT}
        [ `grep SQLSTATE ${TMPOUT} | wc -l` -gt 0 ] && echo `date`": Failed:       ${DB_SCHEMA_NAME}.ETL_DAILY: UPDATE failed" && fclean_up "${DB_SCHEMA_NAME}.ETL_DAILY: UPDATE failed" && return 0
        echo `date`": Info:         `basename $0`: Completed Successfully !" && echo `date`": Info:         `basename $0`: Completed Successfully !" >> ${EXECUTION_LOG}
        [ -f $CM_dsload_prog_ind ] && rm $CM_dsload_prog_ind
        [ -f $DIMJOBLST ] && rm $DIMJOBLST
        [ -f $DIMJOBLST_COMMON ] && rm $DIMJOBLST_COMMON
        [ -f $DIMJOBLST_ENABLED ] && rm $DIMJOBLST_ENABLED
}

Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Syntax error near unexpected token `"Hit <ENTER> to continue:"'

the below code will search attr string inside makefile under the modelno on given path. echo "Enter model no for searching string inside makefile" read inputs2 #find /pools/home_unix/sapte/work/models/model/$inputs2 -name "makefile" | xargs grep "attr" \; #;;I am getting below error.... (7 Replies)
Discussion started by: lathigara
7 Replies
Login or Register to Ask a Question