#!/bin/sh
#
# Probe script for GridSolve 
#
# Arguments:  GridSolve will pass one argument to the probe
# script, which is the identifier of the job to probe.
#
# GridSolve probe scripts should exit with the appropriate
# status as follows:
#
#   0 - the job is still running
#   1 - the job has completed
#   2 - the job terminated abnormally 
#
# $Id: gs_mscc_probe,v 1.1 2006/10/26 20:21:19 yarkhan Exp $


# Possible status results; using unique 4th letter to capture the outcome
# Not_Submitted
# Queued
# Running
# Finished
# Failed
# Cancelled 

# Export the jobid so that it can be seen from the cmd shell
export GRIDSOLVE_JOBID=$1

# Use the cmd shell to run job view
cmd /c job view /scheduler:ms-hn %GRIDSOLVE_JOBID% > job_view_output

# Use the Cygwin shell to scan the output from job_view_output 
# and return the correct value
status=`cat job_view_output | grep Status | cut -b 27 | tr "_unilc" "000122" `

exit $status
