Need help! Linux shell script

Hi all,
I am trying to make a Nodemanager work in RHEL 5
I got this script from 'oraclemiddleware.wordpress.com', and made appropriate changes to suit my weblogic installation.
I keep getting the error, "line 82: syntax error: unexpected end of file".
I have checked every line to make sure all quotes and brackets as properly closed. I also ran it with -x and -nv, but to no avail.
I would really appreciate it, if someone can take a look at the script, and let me know where the problem is.
Here is the whole script:-
--------------------------------------------------------------------------------

#!/bin/sh

MW_HOME=/home/vasan/Oracle/Middleware
JAVA_HOME=/home/vasan/Oracle/Middleware/jrockit_160_29_D1.2.0-10
DAEMON_USER="vasan"
PROCESS_STRING="weblogic.NodeManager"
WL_HOME=/home/vasan/Oracle/Middleware/wlserver_12.1

source $WL_HOME/server/bin/setWLSEnv.sh > /dev/null
export NodeManagerHome=�$WL_HOME/common/nodemanager�
NodeManagerLockFile=�$NodeManagerHome/nodemanager.lok�

PROGRAM=�$MW_HOME/wlserver_12.1/server/bin/startNodeManager.sh�
SERVICE_NAME=`/bin/basename $0`
LOCKFILE=�/var/lock/subsys/$SERVICE_NAME�

RETVAL=0

start() {
  OLDPID=`/usr/bin/pgrep -f $PROCESS_STRING`
  if [ ! -z "$OLDPID" ]; then
    echo �$SERVICE_NAME is already running pid $OLDPID !�
    exit
  fi

  echo -n $�Starting $SERVICE_NAME: �
  /bin/su $DAEMON_USER -c �$PROGRAM &�

  RETVAL=$?
  echo
  [ $RETVAL -eq 0 ] && touch $LOCKFILE
}

stop() {
  echo -n $�Stopping $SERVICE_NAME: �
  OLDPID=`/usr/bin/pgrep -f $PROCESS_STRING`
  if [ "$OLDPID" != "" ]; then
    /bin/kill -TERM $OLDPID
  else
    /bin/echo �$SERVICE_NAME is stopped�
  fi
  echo
  /bin/rm -f $NodeManagerLockFile
  [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
}

restart() {
  stop
  sleep 10
  start
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart|force-reload|restart)
    restart
    ;;
  condrestart|try-restart)
    [ -f$LOCKFILE ] && restart
    ;;
  status)
    OLDPID=`/usr/bin/pgrep -f $PROCESS_STRING`
    if [ "$OLDPID" != "" ];then
      /bin/echo �$SERVICE_NAME is running pid:$OLDPID�
    else
      /bin/echo �$SERVICE_NAME is stopped�
    fi
    RETVAL=$?
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
    exit 1
esac
exit $RETVAL

Thanks in advance!

Just skimming over it; you got wrong double quotes.
� � ,� � ,� � and none of them are equivalent to " ".

1 Like

The line:

echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"

is no syntax that I recogize.

I think it's taking $" to be a variable name and considering the closing quote to be an opening quote. The script hits EOF with no closing quote and there's an error.

I think you meant:

echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"

Cheers!

1 Like

Thanks to both of you (Aia) and (sds9985)
My issue has been resolved.

It's actually correct. From the Kshell manual page:

I assume bash treats it in a similar fashion, but I cannot say for sure.

1 Like