#! /usr/bin/sh
# RUNGETREF -- Bundle getref and upreffile in a single script
# Usage: rungetref obset [obset ...]

# The following lines must be configured for each installation
CDBS_TOP=/data/cdbs1/tools/
SDAS_BIN=/usr/stsci/stsdasx/bin/

# Define the executable names
GETREF=$CDBS_TOP/bin/getref
UPREF=$SDAS_BIN/x_headers.e

# Loop over each observation set
for OBSET
do
    DELTA=/tmp/$$.del
    PFILE=/tmp/$$.dpr
    $GETREF $OBSET >$DELTA || exit
    echo "
input = $DELTA
update = yes
source = 'obc,okr,ref'
verify = no
mode = 'a'
" >$PFILE
    $UPREF upreffile "@$PFILE" || exit
    rm $DELTA $PFILE
done
