#!/bin/csh -f 

# set JAVA = ~ipp/jre1.7.0_03/bin/java
# set JYTHON = ~ipp/jython2.5.3b1/jython.jar

# a bit crude : get the datadir path by interpollation of the PATH element for psconfig
foreach f ( `echo $PATH | tr : ' '` )
  echo $f | grep $PSCONFDIR > /dev/null
  if ($status) continue
  set datadir = `echo $f | sed s/bin\$/share/`
  break
end

set JARDIR = $datadir/jar
set JYDIR = $datadir/jython

# XXX install jython in JARDIR
# set JYTHON = $JARDIR/jython2.5.3b1/jython.jar
set JYTHON = ~/jython2.5.3b1/jython.jar

if (! -r $JYTHON) then
  echo "jython jar file not found, check jython installation"
  exit 2
endif

if ($?JAVA == 0) then
  which java >& /dev/null
  if ($status) then
    echo "java not found, please specify location in environment or install in path"
    exit 2
  endif
  set JAVA = `which java`
endif

set CLASSPATH = $JARDIR/stilts.jar\:$JARDIR/commonst-math-2-2.jar\:$JARDIR/mysql-connector-java-5.1.14-bin.jar\:$JYDIR

if ($#argv < 1) then
  echo "USAGE ippjython (classfile) [options]"
  exit 2
endif

set classfile = $1
shift

$JAVA -Xbootclasspath/a:$CLASSPATH -jar $JYTHON $JYDIR/$classfile $*
