#!/bin/ksh
#
# (c) 2000 Sun Microsystems, Inc.
#

parse_job_status() {

   match=$1

   # throw away the first two lines

   read dummy
   read dummy

   while read f stat pid ppid
   do
      if [ "$pid" = "$match" ]
      then
         print $stat
         return $stat
      fi
   done

   return 255
}


job_status() {

   if [[ "$1" = "" || "$2" = "" ]]
   then
       print usage: $(basename $0) os_job_id pid
       exit 1
   fi

   acctcom -j $1 -b -p -Z -f -v /usr/adm/acct/day/pacct | parse_job_status $2
}

job_status $*
