echo "$tool -> .local_tool_wrapper: $message Exiting ..."
############################ main ##############################
if [ -z "$TRE_PROJECT" ]; then
die "TRE_PROJECT not defined"
TRE_ROOT=$TRE_PROJECT/tools
TOOL_ROOT=$TRE_PROJECT/tools/perlmod/$tool
### Verify TRE_SEARCH and TRE_ENTRY are defined and non-null
if [ -z "$TRE_SEARCH" ]; then
die "TRE_SEARCH not defined"
if [ -z "$TRE_ENTRY" ]; then
die "TRE_ENTRY not defined"
### Get version, based on tool invoked, and $TRE_ENTRY
version=`configsrch $tool $TRE_ENTRY`
die "configsrch returned error code!"
### Verify configsrch delivered a non-null version
if [ -z "$version" ]; then
die "No version set by configsrch"
### Assemble directory-oriented executable ...
### (eliminate the extra layer of shell redirection...)
exe=$TOOL_ROOT/$version/bin/$tool
### Assemble do-file name. If it's there, execute and test status.
exe=$TRE_ROOT/$tool,$version.do
if [ $dostat != 0 ] ; then
die "Error return from do file"
exe=$TRE_ROOT/$tool,$version
die "executable $exe not found!"
### If none of the above executable patterns hit, then die with errors...
echo "FATAL: Couldn't find any executable form:"
echo "FATAL: $TOOL_ROOT/$version/bin/$tool"
echo "FATAL: $TRE_ROOT/$tool,$version.do"
echo "FATAL: $TRE_ROOT/$tool,$version"
die "FATAL: $tool executable not found!"