Unusual Problem

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

#!/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:

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

Kindly help..

You're missing a 'then':

if [ $Export_Status -eq 0 ]
then
  echo "JrePath declared"
elif [ $Export_Status -gt 0 ]
then

Excerpt from the bash manual:

The syntax of the if command is:

          if test-commands; then
            consequent-commands;
          [elif more-test-commands; then
            more-consequents;]
          [else alternate-consequents;]
          fi

Regards

Crosspost

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.