syntax error near unexpected token `elif' | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

syntax error near unexpected token `elif'

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-19-2009
proactiveaditya proactiveaditya is offline
Registered User
 
Join Date: Sep 2009
Last Activity: 22 September 2013, 5:47 PM EDT
Location: Kolkata,India
Posts: 269
Thanks: 17
Thanked 0 Times in 0 Posts
syntax error near unexpected token `elif'

what is wrong with the below script:
---------------------------------------------------------------------------------

Code:
#!/bin/bash

echo "Setting JrePath..."
grep -w "export JrePath" /etc/profile
Export_Status=$?
if [ $Export_Status -eq 0 ]
  echo "JrePath declared"
elif [ $Export_Status -gt 0 ]
  echo "JrePath not declared"
  echo "export JrePath=/etc/alternatives/jre" >> /etc/profile
  echo "JrePath declared"
fi

--------------------------------------------------------------------
I am getting the following error:


Code:
jrepath: line 9: syntax error near unexpected token `elif'
jrepath: line 9: `elif [ $Export_Status -gt 0 ]'

Kindly help..

Last edited by Franklin52; 09-19-2009 at 01:01 PM.. Reason: Please use code tags!
Sponsored Links
    #2  
Old 09-19-2009
dr.house dr.house is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 30 October 2011, 12:05 PM EDT
Location: Switzerland
Posts: 454
Thanks: 4
Thanked 27 Times in 27 Posts
Quote:
Originally Posted by proactiveaditya View Post

Code:
if [ $Export_Status -eq 0 ]
echo "JrePath declared"
elif [ $Export_Status -gt 0 ]
echo "JrePath not declared"
echo "export JrePath=/etc/alternatives/jre" >> /etc/profile
echo "JrePath declared"
fi


Code:
if [ $Export_Status -eq 0 ]
then
  echo "JrePath declared"
elif [ $Export_Status -gt 0 ]
then
  echo "JrePath not declared"
  echo "export JrePath=/etc/alternatives/jre" >> /etc/profile
  echo "JrePath declared"
fi

(Reference)
Sponsored Links
    #3  
Old 09-19-2009
proactiveaditya proactiveaditya is offline
Registered User
 
Join Date: Sep 2009
Last Activity: 22 September 2013, 5:47 PM EDT
Location: Kolkata,India
Posts: 269
Thanks: 17
Thanked 0 Times in 0 Posts
Thanks

Thanks a lot

still wondering how i missed the "then"
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Syntax error near unexpected token tomailraj UNIX for Advanced & Expert Users 2 08-23-2009 10:07 AM
sh syntax error unexpected token done NullPointer Shell Programming and Scripting 5 04-30-2009 10:28 AM
line 3: syntax error near unexpected token `(' camzio UNIX Desktop for Dummies Questions & Answers 4 09-29-2008 11:10 AM
syntax error near unexpected token...what caused? joshuaduan Shell Programming and Scripting 8 05-14-2007 10:02 AM
syntax error at line 33: `elif` unexpected hazy UNIX for Dummies Questions & Answers 4 02-09-2006 02:51 PM



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