#! /bin/sh

#
# Portions of this file Copyright 1999-2005 University of Chicago
# Portions of this file Copyright 1999-2005 The University of Southern California.
#
# This file or a portion of this file is licensed under the
# terms of the Globus Toolkit Public License, found at
# http://www.globus.org/toolkit/download/license.html.
# If you redistribute this file, with or without
# modifications, you must include this notice in the file.
#


. ${GLOBUS_LOCATION}/libexec/globus-script-initializer
globus_source ${libexecdir}/globus-sh-tools.sh


#  CVS Information:
#     $Source: /home/globdev/CVS/globus-packages/gram_client_tools/source/globus-job-status.in,v $
#     $Date: 2005/04/18 21:40:39 $
#     $Revision: 1.4 $
#     $Author: smartin $


PROGRAM_NAME=`echo $0 | ${GLOBUS_SH_SED-sed} -e 's|.*/||g'`
PROGRAM_VERSION='4.6'
PACKAGE='globus_gram_client_tools'
VERSION='4.6'
DIRT_TIMESTAMP='1152282286'
DIRT_BRANCH_ID='63'


short_usage="$PROGRAM_NAME [-help] [-version] [jobID]"

long_usage ()
{
${GLOBUS_SH_CAT-cat} >&2 <<EOF

Usage: ${short_usage}

    $PROGRAM_NAME prints out the status of a job previously started by
    globus-job-submit, identified by the string "jobID". A valid proxy
    certificate is required for this operation to succeed.

    Valid job states are PENDING, ACTIVE, DONE and FAILED.

    Options:
      -help | -usage       Display usage
      -version             Display version


EOF
}

globus_source ${libexecdir}/globus-args-parser-header $*

if [ $# -lt 1 ]; then
    globus_args_short_usage
    exit 1
fi

case "$1" in
    -*)
	globus_args_unrecognized_option "$1"
	;;
esac

${bindir}/grid-proxy-info -exists
if [ $? -ne 0 ]; then
    echo "ERROR: could not find a valid proxy" >&2
    globus_args_short_usage
    exit 1
fi

${bindir}/globusrun -status "$1"

