当将作业打印到CUPS服务器时,可以设置cupsd.conf参数PreserveJobHistory和PreserveJobFiles,以控制要保留多少作业。
CUPS总是将实际的打印作业文件临时存储在/var/spool/cups/目录中。由打印客户端提交的假脱机文件(在CUPS的过滤器转换链开始之前)总是被命名为dNNNNNNNNN-001(以'd‘开头,在’datafile‘中),其中NNNNNN是由CUPS分配的作业ID。如果您提交了一个多文档打印作业,那么第二个文档在同一个作业ID中的假脱机文件名为dNNNNNNNN-002,等等.
同样,同一个目录将保存以另一个字符开始的文件,即控制文件,它们将被命名为cNNNNNN,用于每个作业。
我要剖析这些控制文件文件。
当我使用strings工具时,它只显示了我想要获得的部分内容:
示例:
sudo strings /var/spool/cups/d00089
attributes-charset
utf-8H
attributes-natural-language
en-us
printer-uri
%ipp://localhost:631/printers/hp2B
job-originating-user-name
kurtpfeifleB
job-name
hosts!
copies
finishings
job-cancel-after
job-hold-until
no-hold!
job-priority
job-sheets
noneB
none!
number-up
job-uuid
-urn:uuid:ca854775-f721-34a5-57e0-b38b8fb0f4c8B
job-originating-host-name
localhost!
time-at-creation
time-at-processing
time-at-completed
job-id
job-state
job-state-reasons
processing-to-stop-point!
job-media-sheets-completed
job-printer-uri
(ipp://host13.local:631/printers/hp!
job-k-octets
document-format
text/plainA
job-printer-state-message
job-printer-state-reasons
none而且,strings输出看起来不太好。
问题:是否有一种编程(或其他)方法来剖析这些CUPS作业控制文件,并获得包含所有信息的完整内容?
发布于 2018-12-09 01:31:04
我自己找到了答案。
当您从源编译cups时,有一个子目录CUPS。它还保存特定于此子this的Makefile。这个Makefile包含一个名为“unittest”的构建目标,它是,而不是默认构建的!
但是,如果您运行make unittests,它不仅会运行其单元测试,而且还会创建一些命令行实用程序,这些实用工具也可能在单元测试之外得到很好的应用!
为了解决我的问题,事实证明testipp CLI实用程序是纯金的。看看你自己:
sudo ./testipp /var/spool/cups/c00089
operation-attributes-tag:
attributes-charset (charset): utf-8
attributes-natural-language (naturalLanguage): en-us
job-attributes-tag:
printer-uri (uri): ipp://localhost:631/printers/hp
job-originating-user-name (nameWithoutLanguage): kurtpfeifle
job-name (nameWithoutLanguage): hosts
copies (integer): 1
finishings (enum): none
job-cancel-after (integer): 10800
job-hold-until (keyword): no-hold
job-priority (integer): 50
job-sheets (1setOf nameWithoutLanguage): none,none
number-up (integer): 1
job-uuid (uri): urn:uuid:ca854775-f721-34a5-57e0-b38b8fb0f4c8
job-originating-host-name (nameWithoutLanguage): localhost
time-at-creation (integer): 1472022731
time-at-processing (integer): 1472022731
time-at-completed (integer): 1472022732
job-id (integer): 89
job-state (enum): completed
job-state-reasons (keyword): processing-to-stop-point
job-media-sheets-completed (integer): 0
job-printer-uri (uri): ipp://host13.local:631/printers/hp
job-k-octets (integer): 1
document-format (mimeMediaType): text/plain
job-printer-state-message (textWithoutLanguage): Printing page 1, 4% complete.
job-printer-state-reasons (keyword): none不幸的是,运行make install不会将这个工具安装到系统中,因此它永远不会暴露给任何CUPS管理员!此外,Linux发行版包可能很容易忽略它。对于大多数CUPS极客来说,testipp是不受关注的。
还有一些更有用的实用工具是由make unittests构建的。
这些是: testadmin, testarray, testcache, testclient, testconflicts, testcreds, testcups, testdest, testfile, testgetdests, testhttp, testi18n, testlang, testoptions, testppd, testpwg, testraster, testsnmp。
不幸的是,目前没有Linux发行版构建和发布这些有用的工具。因此,如果你认识一个发行版打包者,请告诉他这里的发现,并请她为的所有终端用户打包一个很好的包,或者cups-test-utils.deb或cups-test-utils.tgz,或者他的$distro的包名后缀!
发布于 2020-01-12 11:14:25
我也有一个类似的问题--我们需要工作的持续时间,并且发现了你的线程。到目前为止,testIPP运行良好,但我不想只为这些整洁的工具编译cups,我还需要它集成到其他基于go的应用程序中。
我已经开始在go中实现小的CLI,它也可以用作库https://github.com/ui-kreinhard/go-cups-control-files
https://stackoverflow.com/questions/53688075
复制相似问题