LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   why am getting error ksh: syntax error: `fi' unexpected while running script (https://www.linuxquestions.org/questions/linux-newbie-8/why-am-getting-error-ksh-syntax-error-%60fi-unexpected-while-running-script-667926/)

deb4you 09-06-2008 05:03 AM

why am getting error ksh: syntax error: `fi' unexpected while running script
 
Hi All

I am getting error in one of my script on Sun Solaris box while running in the script thru command line but from cronjob it is working ........... here is the details..........

s024[/home/oracle]$. /home/oracle/scripts/arch_backup.ksh proddb
ksh: syntax error: `fi' unexpected

the part of script where if statement is used...........

chk_err=`cat $LOG_PATH/archbck_$ORACLE_SID.$dt.log | grep "ERROR" | wc -l`
chkerr=${chk_err:-0}
if [ $chkerr -ne 0 ]
then
# mailx -s "$HOST Archbkp $ORACLE_SID Failed" $MAILTO < $LOG_PATH/archbck_$ORACLE_SID.$dt.log

exit 1

else
# mailx -s "$HOST Archbkp $ORACLE_SID Successful" $MAILTO < $LOG_PATH/archbck_$ORACLE_SID.$dt.log
fi
exit 0

---------------------------------

could any pls point out the cause of this error
thanks in advance

Simon Bridge 09-06-2008 05:22 AM

Make sure that is the only instance of "fi" in the entire script?

uselpa 09-06-2008 05:48 AM

It's because the 'else' clause is empty.
Just put a # before the else as well.

deb4you 09-06-2008 07:40 AM

Thanks

u r right since I made comment the else part after that it was happening.
Now I made comment to else as well and it is running fine from command prompt.
One more doubt........
Now it is running fine from command prompt but that window got exit.
any problem still exist or it is normal ......
pls note that I add #else with the script.

Thanks once more for you kind and valuable reply.

uselpa 09-06-2008 08:37 AM

Quote:

Originally Posted by deb4you (Post 3271464)
Now it is running fine from command prompt but that window got exit.

I'm sorry but I don't understand what you mean by this.
Which window?


All times are GMT -5. The time now is 01:39 AM.