#!/bin/sh # # this is a location independent way of executing perl scripts # it will first find where perl is and then exec it. # # # first find the sms command, since it may be specified without the # complete path # execdir=`dirname $0` if [ ! -f $1 ]; then # the caller did not specify the complete path of the sms command if [ -e ${execdir}/$1 ]; then command=${execdir}/"$1" else if [ "${MWHOME:-notset}" != "notset" ]; then command=${MWHOME}/../sms/"$1" else echo "cannot find sms command (perl script) $1" exit 1; fi fi else command="$1" fi shift # pop command argument if [ "${MWHOME:-notset}" = "notset" ]; then # # case of stand alone execution # setup=${execdir}/setup-mwuser if [ ! -f "$setup" ] ;then setup=../mw/setup-mwuser if [ ! -f "$setup" ] ;then echo "Error: Cannot find 'setup-mwuser'" exit 1 fi fi . "$setup" perl="${execdir}/mwperl-${MWARCH_OS}" if [ ! -f ${perl} ];then perl="${execdir}/mwperl" if [ ! -f ${perl} ];then perl=`whence perl` if [ "${perl:-notset}" = "notset" ]; then perl=/usr/local/bin/perl if [ ! -f ${perl} ];then echo "cannot find perl to execute command ${command} $@" exit 1 fi fi fi fi else # within the mainwin installation perl=${MWHOME}/bin-${MWARCH_OS}/mwperl fi exec ${perl} ${command} "$@"