Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lpstat based on File???

Status
Not open for further replies.

bgreen

Programmer
Feb 20, 2003
185
CA
Here is an lpstat output:

Queue Dev Status Job Files User PP % Blks Cp Rnk
------- ----- --------- --- ------------------ ---------- ---- -- ----- --- ---
iis hp@LR DOWN
QUEUED 779 tag.lst applmgr 18 1 1

How can I get an lpstat output based on the File (tag.lst)???
 
You can't, directly, but you might be able to parse the information you want out of the files in /var/spool/lpd/qdir.

The job number is on the first line, and the title (listed under Files in lpstat, but not necessarily the filename) appears toward the end of the file, on the line before the user.

Another option would be to parse the output of "lpstat -a".



Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

 
I am able to parse out the job

lpstat |sed -n '/tag.lst/p'

this will give me

QUEUED 779 tag.lst applmgr 18 1 1

I would also like to see the queue it belongs to. Do you have any suggestions?
 
Code:
lpstat | perl -ne '
$curq = $1 if /^(\S?)\s/;
print "$curq $_\n" if /tag.lst/;
'

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

 
This din't give me the queue, it gave me the same results as I stated above.
 
Not sure where my mind was on that regex.

replace

Code:
(^\S?\s)

with

(^\S+)

that should do it.

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

 
What if I want to pass the name of the file as a variable?

lpstat -W| perl -ne '
$curq = $1 if /^(\S+)/;
print "$curq $_\n" if /\$NAME/;'

This does not work. What would?
 
Code:
NAME=string_to_search_for

lpstat -W| perl -ne '
$curq = $1 if /^(\S+)/;
print "$curq $_\n" if /$ENV{"NAME"}/;'

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top