Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have two files, an env file and a run file. When I deploy them to my Ubuntu Server box I get the error:

./start-admin: line 10: syntax error: unexpected end of file

If I deploy and then add a newline to the end of the file, it will show the error. If I then remove it the error goes away. If I deploy again and don't add the newline, it still shows the error, but if I then add a newline the error goes away. What could possibly cause that?

Below are my scripts:

env:

if [ "x${WD}" == "x" ];  then echo "missing required conf \"\${WD}\"" >&2; exit -1; fi

export JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk.x86_64
export JAR_FILE="$WD/mfa-admin.jar"
export MYSQL_URL=url1
export MYSQL_USER=root
export MYSQL_PASSWORD=pwd
export DB_URL=url2
export DB_USER=user
export DB_PASSWORD=pwd2

export EMAIL_HOST=mail-inbox
export EMAIL_PORT=25
export EMAIL_PERMISSION=false
export FAKE_EMAIL=email
export ACTIVATION_URL=url

export BIND_HOST=0.0.0.0
export BIND_PORT=8282

start:

WD=`dirname $0`;

JAVA_OPTS=""

if [ -r "$WD/admin.env.conf" ]; then
  . $WD/admin.env.conf
fi

# required stuff
if [ "x${JAVA_HOME}" == "x" ];                              then echo "missing required conf \"\${JAVA_HOME}\""                                                  >&2; exit -1; fi
if [ "x${JAR_FILE}" == "x" ];                               then echo "missing required conf \"\${JAR_FILE}\""                                                   >&2; exit -1; fi
if [ "x${MYSQL_URL}" == "x" ];                   then echo "missing required conf \"\${MYSQL_URL}\""        >&2; exit -1; fi
if [ "x${MYSQL_USER}" == "x" ];                  then echo "missing required conf \"\${MYSQL_USER}\""       >&2; exit -1; fi
if [ "x${MYSQL_PASSWORD}" == "x" ];              then echo "missing required conf \"\${MYSQL_PASSWORD}\""   >&2; exit -1; fi
if [ "x${DB_URL}" == "x" ];                      then echo "missing required conf \"\${DB_URL}\""                            >&2; exit -1; fi
if [ "x${DB_USER}" == "x" ];                     then echo "missing required conf \"\${DB_USER}\""                           >&2; exit -1; fi
if [ "x${DB_PASSWORD}" == "x" ];                 then echo "missing required conf \"\${DB_PASSWORD}\""                       >&2; exit -1; fi

if [ "x${EMAIL_HOST}" == "x" ];                  then echo "missing required conf \"\${EMAIL_HOST}\""                       >&2; exit -1; fi
if [ "x${EMAIL_PORT}" == "x" ];                  then echo "missing required conf \"\${EMAIL_PORT}\""                       >&2; exit -1; fi
if [ "x${EMAIL_PERMISSION}" == "x" ];            then echo "missing required conf \"\${EMAIL_PERMISSION}\""                 >&2; exit -1; fi
if [ "x${FAKE_EMAIL}" == "x" ];                  then echo "missing required conf \"\${FAKE_EMAIL}\""                       >&2; exit -1; fi
if [ "x${ACTIVATION_URL}" == "x" ];              then echo "missing required conf \"\${ACTIVATION_URL}\""                   >&2; exit -1; fi

if [ "x${BIND_HOST}" == "x" ];                    then echo "missing required conf \"\${BIND_HOST}\""                         >&2; exit -1; fi
if [ "x${BIND_PORT}" == "x" ];                    then echo "missing required conf \"\${BIND_PORT}\""                         >&2; exit -1; fi

JAVA_OPTS="${JAVA_OPTS} -Dmysql.URL=\"${MYSQL_URL}\" "
JAVA_OPTS="${JAVA_OPTS} -Dmysql.USER=\"${MYSQL_USER}\" "
JAVA_OPTS="${JAVA_OPTS} -Dmysql.PASSWORD=\"${MYSQL_PASSWORD}\" "
JAVA_OPTS="${JAVA_OPTS} -Ddb.URL=\"${DB_URL}\" "
JAVA_OPTS="${JAVA_OPTS} -Ddb.USER=\"${DB_USER}\" "
JAVA_OPTS="${JAVA_OPTS} -Ddb.PASSWORD=\"${DB_PASSWORD}\" "

JAVA_OPTS="${JAVA_OPTS} -DEMAIL_HOST=\"${EMAIL_HOST}\" "
JAVA_OPTS="${JAVA_OPTS} -DEMAIL_PORT=\"${EMAIL_PORT}\" "
JAVA_OPTS="${JAVA_OPTS} -DEMAIL_PERMISSION=\"${EMAIL_PERMISSION}\" "
JAVA_OPTS="${JAVA_OPTS} -DFAKE_EMAIL=\"${FAKE_EMAIL}\" "
JAVA_OPTS="${JAVA_OPTS} -DACTIVATION_URL=\"${ACTIVATION_URL}\" "

JAVA_OPTS="${JAVA_OPTS} -DBIND_HOST=\"${BIND_HOST}\" "
JAVA_OPTS="${JAVA_OPTS} -DBIND_PORT=\"${BIND_PORT}\" "

JAVA="$JAVA_HOME/bin/java"

eval \"$JAVA\" $JAVA_OPTS -cp "${WD}:${JAR_FILE}" VertxNode
share|improve this question
    
Does your script has DOS line endings? –  jordanm Feb 27 '13 at 16:27
5  
try to convert it to unix-style line endings with dos2unix –  Serge Feb 27 '13 at 16:36
2  
You don't have to rewrite, just use dos2unix as suggested. Windows, Mac and Linux use different characters for line endings, that's all. –  schaiba Feb 27 '13 at 16:49
2  
Note that you must begin your scripts with #!/bin/bash. Otherwise they will be executed with /bin/sh and not bash. You could make your scripts compatible with /bin/sh by using [ "x${foo}" = x ] instead of ==, that's the only bash extension that you use. You would still need to start the script with #!/bin/sh. –  Gilles Feb 27 '13 at 23:16
2  
Run your script as bash -x start-admin then post debug output. –  Rahul Patil Feb 28 '13 at 1:49

1 Answer 1

When I have obtained this message, it is the result of mismatched `, ', or " strings within the script. Sometimes this also happens with mismatched if/then/fi, do/while, or case/esac statements.  I'd strongly check out your scripting closely.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.