代码之家  ›  专栏  ›  技术社区  ›  Kurt Pfeifle

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

  •  0
  • Kurt Pfeifle  · 技术社区  · 6 年前

    当将工作打印到CUPS服务器时,可以设置 CuPSD.CONF 参数 PreserveJobHistory PreserveJobFiles 控制你想保留多少工作。

    CUPS总是将实际的打印作业文件临时存储在目录中 /var/spool/cups/ . 打印客户端提交的spool文件(在cups的转换过滤器链启动之前)总是命名为 DNNNNN-01 (在“datafile”中以“d”开头),其中 NNNNN 是CUPS分配的作业ID。如果提交多文档打印作业,则同一作业id内的第二个文档的spool文件将命名为 DNNNNN-02 ,等等…

    同样,同一目录将保存以另一个字符开头的文件 控制文件 他们将被命名为 CNNNNN 每项工作。

    我想剖析这些控制文件。

    当我使用 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
    

    而且,那个 输出看起来不太好。

    问题: 有没有一种编程(或其他)方法来剖析这些cups作业控制文件,并获得包含所有信息的完整内容?

    1 回复  |  直到 6 年前
        1
  •  0
  •   Kurt Pfeifle    6 年前

    我自己找到了答案…

    从源代码编译cups时,有一个子目录 杯子 . 它也有一个 生成文件 特定于这个街道。该生成文件包含名为 “单元测试” 哪个是 不是 默认生成!

    但是如果你跑 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发行版打包程序可能很容易忽略它。 睾丸 对大多数杯具极客来说都是暗箱操作。

    有一些更有用的实用程序是由 进行单元测试 :
    这些是: testadmin, testarray, testcache, testclient, testconflicts, testcreds, testcups, testdest, testfile, testgetdests, testhttp, testi18n, testlang, testoptions, testppd, testpwg, testraster, testsnmp .

    不幸的是,目前还没有linux发行版构建和发布这些有用的工具。 所以,如果你认识一个发行版包装商,请把他指给这里的这个发现,让她包装一个漂亮的包 所有最终用户 cups-test-utils.rpm cups-test-utils.deb cups-test-utils.tgz 或者不管他的$distro的包名后缀是什么! `