Riaan's SysAdmin Blog

My tips, howtos, gotchas, snippets and stuff. Use at your own risk!

PrintingSolaris

Solaris lp printer queue job ids

If you have a Unix queue name that is long, your job id's may be cut off in the list. So you will be trying to troubleshoot/cancel jobs with "not-found" messages.

lpstat output. Note all job id’s cut off…

printer company_check_M402n now printing company_check_M402n-19101. enabled since Wed Dec 28 05:54:55 2016. available.
[..]
company_check_M402n-191 ebsuser_a         1165   Dec 27 15:36

Correct job id’s shown with a short script. Script below is self explanatory:

~/scripts# python check_spool.py 
Listing LP spool job id's
company_check_M402n-19104

# cat check_spool.py 
from os import listdir,path
from os.path import isfile, join
print "Listing LP spool job id's"
spoolpath='/var/spool/lp/requests/localhost/'
onlyfiles = [f for f in listdir(spoolpath) if isfile(join(spoolpath, f))]
for f in onlyfiles:
  fname = path.abspath(spoolpath + f)
  with open(fname) as spoolfile:
    lines = spoolfile.readlines()
    print lines[0].strip()

admin

Bio Info for Riaan