#!/bin/csh

set usage = "USAGE: job_in_q JOBNAME"

if ( $#argv < 1 ) then 
	echo $usage
	exit 2
endif 

set job = $1

#set job_names = `qstat | cut -c 17-26`
set job_names = `qstat | cut -c 21-36`

#	return busy if qstat failed
if ( $status != 0 ) then
	echo 1
	exit 1
endif 

foreach job_name ( $job_names )
	if ( $job_name == $job ) then
		echo 1 
		exit 1
	endif 
end 

echo 0
exit 0
