#!/bin/bash
#
# runelastixlinux
#
# Script to run elastix on linux when the 
# libANNlib.so cannot be found.
# 
# Usage:
#
#   runelastixlinux ...
#
# with ... referring to all arguments you normally
# would use for elastix.
#


# find elastix executable that is used
whichelastix=`which elastix`

# extract the path to elastix
#
# ${string%substring}
# strips shortest match of $substring from back of $string.
elastixpath=${whichelastix%/elastix}

# add the path temporarily to the LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$elastixpath:$LD_LIBRARY_PATH

# run elastix with the supplied command-line arguments
elastix $*

# after exitting this script, the LD_LIBRARY_PATH is
# automatically as it was before running this script.

