#! /bin/sh -f

# Globus Job Manager PBS interface script for deleting a job
# Author:               Doru Marcusiu (NCSA)
# Last Modified:        6/24/98
#
# This script uses information obtained from a file passed as the
# script's argument. This file contains a list of environment variables
# which are set by way of "sourcing" the file from this script. One of
# the evironment variables set as a result of this action is then used
# to obtain the job id for the job to be deleted. Once the job id
# is determined the PBS qdel command is used to delete the job.

. ${GLOBUS_LOCATION}/libexec/globus-script-initializer

globus_source ${libexecdir}/globus-gram-protocol-constants.sh
globus_source ${libexecdir}/globus-sh-tools.sh
globus_source ${libexecdir}/globus-gram-job-manager-tools.sh

qdel=${GLOBUS_GRAM_JOB_MANAGER_QDEL-qdel}

arg_file=$1

        # Check for the argument file. If it does not exist
        # then return with an error immediately

if [ ! -f $arg_file ] ; then
   echo GRAM_SCRIPT_ERROR:$GLOBUS_GRAM_PROTOCOL_ERROR_BAD_SCRIPT_ARG_FILE
   exit 1
fi

        # Source the argument file to set environment variables
        # defining all the job arguments

. $arg_file

        # If a logfile name has been defined in then activate debug mode

if [ $grami_logfile = "/dev/null" ] ; then
    DEBUG_ECHO=:
else
    DEBUG_ECHO=echo
fi

$DEBUG_ECHO in gram_script_ng_rm >> $grami_logfile
$DEBUG_ECHO ng does not support job deletion in that way: $grami_job_id >> $grami_logfile

	# Only GRAM_SCRIPT_SUCCESS or GRAM_SCRIPT_ERROR from this script
	# is expected to be returned. The success or failure of the request
	# to delete the job is inconsiquencial.

echo GRAM_SCRIPT_ERROR:999

$DEBUG_ECHO "exiting gram_script_ng_rm\n\n" >> $grami_logfile

exit
