Unidata McIDAS-X
Unix shell script, mcrun.sh
#!/bin/sh -f
#--------------------------------------------------------------------------
#
# Name: mcrun.sh
#
# Purpose: Bourne shell script used to run a sequence of McIDAS commands
# outside of a McIDAS-X session.
#
# Syntax: mcrun.sh
#
# Notes: Environment variables that need to be set for McIDAS commands
# to run outside of a McIDAS-X session:
#
# MCHOME - the home directory for the user running mcrun.sh
#
# MCDATA - the user's McIDAS-X working directory. NOTE: this
# directory should also be the first directory
# specified in MCPATH.
#
# MCPATH - colon separated list of directories that contain
# McIDAS data files, ancillary data files, and help
# files
#
# PATH - a colon separated list of directories that
# Unix will search when looking for executables.
# NOTE: the ~mcidas/bin directory should be first in
# the list of directories that will be searched.
#
# LD_LIBRARY_PATH - the search path for sharable libraries;
# this should be the same search path as the one
# used by the McIDAS session
#
# MCBATCHFILE.BAT - the name of the McIDAS BATCH file that
# you want to run.
#
# This is a Bourne shell script. All statements must conform to
# Bourne shell scripting syntax.
#
# The example PATH and LD_LIBRARY_PATH definitions are set
# for Sun Solaris. AIX and HP-UX users need to change
# LD_LIBRARY_PATH everywhere in this file to what is appropriate
# on their systems
#
# AIX: LD_LIBRARY_PATH -> LIBPATH
# HPUX: LD_LIBRARY_PATH -> SHLIB_PATH
#
#
# History: 20000607 - Written for Unidata McIDAS-X, -XCD 7.70
#
#--------------------------------------------------------------------------
# Define macros needed for McIDAS-7.X environment
#
# MCHOME - set this to the HOME directory of the user McIDAS was installed as
#
# MCDATA - this will be set according to who is running the script:
#
# user MCDATA
# ----------+---------------------
# mcidas $HOME/workdata
# other $HOME/mcidas/data
#
# MCPATH - this is a colon-separated list of directories McIDAS will search
# when looking for anciallary data (e.g., map databases, enhancements,
# stretch tables, etc.) and data (e.g., AREA, MDXX, GRID, and TEXT
# files.
#
# The $MCDATA directory should _always_ be the first MCPATH directory!
#
# MCLOG - the name of the file to log output to; defaulted to
# $MCDATA/mcrun.log
#
# MCTABLE_READ - a quoted, semi-colon-separated list of directories to search
# for McIDAS-X DATALOCation information. This is typically
# MCTABLE_READ="$MCDATA/MCTABLE.TXT;$MCHOME/data/ADDESITE.TXT"
# but can be expanded to suit the user's needs.
#
# PATH - Unix shell search PATH with $MCHOME/bin being the first directory.
#
# LD_LIBRARY_PATH - most likely not needed, but put in for future use
#
SHELL=sh
export SHELL
#
# First, define MCHOME as the HOME directory for the user under which
# McIDAS-X is installed.
#
MCHOME=/home/mcidas
#
# Find out who is trying to run the script. Don't allow 'root'!
#
case `id` in
'uid=0('*)
echo "ERROR: cannot execute as user 'root'"
exit 1
;;
uid=?'(mcidas)'* |\
uid=??'(mcidas)'* |\
uid=???'(mcidas)'* |\
uid=????'(mcidas)'* |\
uid=?????'(mcidas)'* |\
uid=??????'(mcidas)'* |\
uid=???????'(mcidas)'* )
MCDATA=$HOME/workdata
;;
*)
MCDATA=$HOME/mcidas/data
;;
esac
#
# Set MCPATH using MCDATA and MCHOME
#
MCPATH=${MCDATA}:$MCHOME/data:$MCHOME/help
#
# Define MCLOG to be $MCDATA/mcrun.log
#
MCLOG=$MCDATA/mcrun.log
#
# Set MCTABLE_READ based on the existence of $MCDATA/MCTABLE.TXT. Users
# should modify this section to match their setup if it does not follow
# the recommendations in the Unidata McIDAS-X online documentation
# for configuring user accounts.
#
if [ -f "${MCDATA}/MCTABLE.TXT" ]; then
MCTABLE_READ="${MCDATA}/MCTABLE.TXT;${MCHOME}/data/ADDESITE.TXT"
else
MCTABLE_READ="${MCHOME}/data/ADDESITE.TXT"
fi
#
# Setup PATH so that the McIDAS-X executables can be found
#
PATH=$MCHOME/bin:$PATH
#
# Set LD_LIBRARY_PATH to include all directories (other than those searched
# by default) that are needed to be searched to find shared libraries.
#
LD_LIBRARY_PATH=$MCHOME/lib:$LD_LIBRARY_PATH
#
# Send all textual output to the log file
#
exec 2>$MCLOG 1>&2
#
# Export the environment variables specified above
#
export MCHOME MCDATA MCLOG MCPATH MCTABLE_READ PATH LD_LIBRARY_PATH
#
# Now run 'mcenv' to create a McIDAS-X environment in which the McIDAS
# binary commands will run.
#
# It is the user's responsibility to put the commands they want to run
# in the following.
#
cd $MCDATA
mcenv << EOF
# put McIDAS-X commands you want to run here, one command per line.
# Example (note that these lines are commented out!!):
#
# dataloc.k ADD RTGINI adde.unidata.ucar.edu
# imgdisp.k RTGINI/GE1KVIS STA=KMIA EU=IMAGE SF=YES REFRESH='EG;MAP H'
# frmsave.k 1 miamivis.gif
# done
exit
EOF
# Done
exit 0