LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-06-2008, 05:03 AM   #1
deb4you
LQ Newbie
 
Registered: Sep 2008
Posts: 2

Rep: Reputation: 0
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
 
Old 09-06-2008, 05:22 AM   #2
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
Make sure that is the only instance of "fi" in the entire script?
 
Old 09-06-2008, 05:48 AM   #3
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
It's because the 'else' clause is empty.
Just put a # before the else as well.
 
Old 09-06-2008, 07:40 AM   #4
deb4you
LQ Newbie
 
Registered: Sep 2008
Posts: 2

Original Poster
Rep: Reputation: 0
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.
 
Old 09-06-2008, 08:37 AM   #5
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
Quote:
Originally Posted by deb4you View Post
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax error near unexpected token `fi' Warmduvet Programming 21 10-08-2013 10:28 AM
compiling error: unexpected token `fi' rem1986 Linux - Kernel 7 12-10-2007 01:11 PM
Backup Script error "line 31: syntax error: unexpected end of file" eswanepoel General 7 12-07-2007 09:28 AM
syntax error near unexpected token `fi' sureshkumar.repaka Linux - General 7 08-19-2007 10:14 PM
Trouble with Bash -- syntax error near unexpected token `fi' anamericanjoe Programming 5 05-19-2006 02:59 PM


All times are GMT -5. The time now is 01:35 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration