Showing results for 
Search instead for 
Did you mean: 


Chui Kock You_1
Frequent Advisor



I’m trying to build the function of canceling Unix’s print jobs from my application as follows:

From my application, use the lpstat –u command to list out the currently lined-up print jobs (by user) & dump the result onto a text file
Then the application will read the text file to determine the print jobs’ IDs so that these IDs can be displayed out to the end user for selection (to select which Jobs to cancel)
The problem is that in HP-UX 11.23, the results generated by the lpstat –u command are different from HP-UX 11.0 & 11i; the followings are the examples:

In HP-UX 11.0:

# lpstat -uong

axis_p1_pr1-8932 ong priority 0 Aug 21 14:24 on axis_p1_pr1

(standard input) 2726 bytes

axis_p1_pr1-8933 ong priority 0 Aug 21 14:24 on axis_p1_pr1

(standard input) 2726 bytes

In HP-UX 11.23:

# lpstat -uong

cps1_pr4-2 ong priority 0 Aug 21 15:05 on cps1_pr4

(standard input) 2743 bytes

(standard input) 2743 bytes

cps1_pr4-3 ong priority 0 Aug 21 15:05

(standard input) 2742 bytes

printer queue for cps1_pr4

no entries

demo: sending to

You can see that in HP-UX 11.0, it only listed out the job ID + another line for the size of the print job; I can just simply take the first line to get the job ID & ignore the second line, take the third line & ignore the fourth line, and soon…!

However, in HP-UX 11.23, it actually listed out more information, like 2 lines for the size of the print job + some other additional detail lines at the end of the listing; this make me hard to determine which is the job ID and which is not, especially when I have more than 1 print jobs lined-up in the spooler! I have tried to use some other options like lpstat & lpstat –o, but they still give me the same additional detail lines!

Thus, I would like to seek for your advice on how to generate a simple list just like what the HP-UX 11.0 does! My e-mail address is

Dennis Handly
Acclaimed Contributor


It appears this is a simple matter of scripting. You either can built up a complex state machine in awk or see if you can analyze what lines you do and don't want.

You could remove lines with "bytes". Or better yet only select lines with "-" followed by "priority":
$ lpstat -uong | grep "-.* priority"

If you want only the IDs, you can pipe it to awk:
$ ... | awk '{print $1}'

You do know of course that cancel(1) takes a -u option? (But you said you wanted to give your users a choice.)