首页 文章

如何剖析CUPS作业控制文件'/var/spool/cups/cNNNNNN'?

提问于
浏览
0

将作业打印到CUPS服务器时,可以设置cupsd.conf参数 PreserveJobHistoryPreserveJobFiles 来控制要保留的作业数 .

CUPS始终将实际打印作业文件临时存储在目录 /var/spool/cups/ 中 . 打印客户端提交的假脱机文件(在CUPS的过滤器转换链开始之前)始终命名为dNNNNNN-001(以'datafile'中的'd'开头),其中NNNNNN是CUPS分配的作业ID . 如果您提交多文档打印作业,则同一作业ID中的第二个文档的假脱机文件名为dNNNNNN-002,依此类推......

此外,同一目录将保存以另一个字符开头的文件,控制文件和每个作业的名称为cNNNNNN .

我想剖析这些控制文件文件 .

当我使用 strings 工具时,它只显示我想要获得的部分内容:

Example:

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 输出看起来不太好 .

Question: 是否有程序化(或其他)方式来剖析这些CUPS作业控制文件,并获得包含所有包含信息的完整内容?

1 回答

  • 0

    我自己找到了答案...

    从源代码编译CUPS时,有子目录cups . 它还包含特定于此子目录的Makefile . 该Makefile包含一个名为"unittests"的构建目标,默认情况下为 NOT 构建!

    但是如果你运行 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 构建了一些更有用的实用程序:
    These are: testadmin, testarray, testcache, testclient, testconflicts, testcreds, testcups, testdest, testfile, testgetdests, testhttp, testi18n, testlang, testoptions, testppd, testpwg, testraster, testsnmp .

    不幸的是,目前没有Linux发行版构建并提供这些有用的工具 . So if you know a distro packager, please point him to this discovery here and ask her to package a nice bundle 适用于 cups-test-utils.rpm 的所有最终用户,或者 cups-test-utils.debcups-test-utils.tgz 或者他的$发行版的包名称后缀! `

相关问题