From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM" 12-JUN-1993 12:15:58.75
To:	EVERHART
CC:	
Subj:	Re: Killing all print jobs in a queue

X-Newsgroups: comp.os.vms
From: jwilkinson@lucy.claremont.edu (James Wilkinson)
Subject: Re: Killing all print jobs in a queue
Message-Id: <1993Jun4.183935.1@lucy.claremont.edu>
Lines: 60
Sender: news@MUDDCS.CLAREMONT.EDU (The News System)
Organization: Harvey Mudd College
Date: Sat, 5 Jun 1993 02:39:35 GMT
To: Info-VAX@kl.sri.com
X-Gateway-Source-Info: USENET

In article <aslagle.47.0@amoco.com>, aslagle@amoco.com (Andy Slagle) writes:
> Is there a simple way to kill all of the print jobs in a queue?
> 
> Andy Slagle.....aslagle@amoco.com

If it isn't convenient to delete and re-create the queue, try the following
command procedure:

$! EMPTY_QUEUE.COM - deletes all jobs from specified queue.
$	verify = 'F$VERIFY(F$TRNLNM("DCL_debug"))
$!
$! Parameter: p1 - queue name
$!
$! Author:	James Wilkinson
$! Date:	8 September 1991
$!
$! This procedure searches through the indicated batch queue, deleting ALL jobs
$! residing in that queue, given that the caller has privilege to do so.
$!
$	if (p1 .eqs. "")			! check for queue name
$	 then
$	  write SYS$ERROR "EMPTY_QUEUE: no queue was specified."
$	  exit
$	endif
$! 
$	dummy = F$GETQUI("cancel_operation")	! remove any old context
$	deleted = 0		  		! how many jobs we delete
$!
$! initialize a new context
$!
$	queue_name = F$GETQUI("display_queue","queue_name",p1,"wildcard")
$!
$	if (queue_name .eqs. "")		! they gave us a bad queue
$	 then
$	  write SYS$ERROR "EMPTY_QUEUE: no such queue as ''p1'."
$	  exit
$	endif
$!
$ NEXT_JOB:
$!
$! get the job entry number
$!
$	entry = F$GETQUI("display_job","entry_number",,"all_jobs")
$!
$	if entry .nes. ""
$	 then
$	  delete /entry='entry 'p1
$	  deleted = deleted + 1
$	  goto NEXT_JOB
$	endif
$
$	if (deleted .gt. 0) then -		! let them know what we did
 	  write SYS$OUTPUT F$FAO("EMPTY_QUEUE: !SL job!%S removed from !AS.", -
 	    deleted, p1)
$	verify = F$VERIFY(verify)
$!
$	exit

James Wilkinson
jwilkinson@hmcvax.claremont.edu

