#!/bin/sh
#
#	This script file starts the Java Debugger. To run the debugger,
#	the following two files are needed: Debug.jar and jdbcdrv.zip.
#
#	Usage is : jdebug  <ASE's host machine name> <ASE's port number> 
#			   <login name of ASE user> <password of user> 
#			   <Path to directory containing Debug.jar (optional) 

MACHINE=$1
PORT=$2
USER=$3
PWD=$4
JARPATH=$5

if [ "$#" -lt 4 ]
then
	echo "Usage: jdebug  <ASE's host machine name> <ASE's port number> <login name of ASE user> <password of user> <Path to directory containing Debug.jar (optional)>"
	exit
fi

if [ $JARPATH ]
then
	if [ ! -r $JARPATH/Debug.jar ]
	then
		echo "Debug.jar is not present at $JARPATH"
	else
		jre -nojit -classpath ${JARPATH}/Debug.jar:$CLASSPATH sybase.vm.Debug jdbc:sybase:Tds:${MACHINE}:${PORT} ${USER} ${PWD}

	fi
elif [ -r $SYBASE/$SYBASE_ASE/debugger/Debug.jar ]
then
	jre -nojit -classpath $SYBASE/$SYBASE_ASE/debugger/Debug.jar:$CLASSPATH sybase.vm.Debug jdbc:sybase:Tds:${MACHINE}:${PORT} ${USER} ${PWD}

elif [ "`echo $CLASSPATH`" ]
then
	jre -nojit -classpath $CLASSPATH sybase.vm.Debug jdbc:sybase:Tds:${MACHINE}:${PORT} ${USER} ${PWD}
else
	echo "Set CLASSPATH environment variable to point to Debug.jar as the FIRST element or supply the path to the directory containing the jar file as the fifth input parameter"
	exit
fi
