Ubuntu

使用 lpstat 獲取 lp 作業狀態

  • December 11, 2013

在 ubuntu 中,我想使用命令行獲取列印作業的狀態。當我使用 lp 將作業發送到列印機時,我可以在工作列小程序中看到列印作業的狀態。例如,當我將作業發送到關閉的列印機時,我看到一個作業顯示“待處理”。

但是,當我執行 lpstat -t 時,我看到的只有以下內容:

scheduler is running
system default destination: Brother_MFC-7340
device for BRFAX: usb:/dev/usb/lp0
device for Brother_MFC-7340: usb://Brother/MFC-7340?serial=000G9N299107
device for MFC-7340: usb://Brother/MFC-7340?serial=000G9N299107
device for MFC7340: usb://Brother/MFC-7340?serial=000G9N299107
BRFAX accepting requests since Tue 03 Dec 2013 10:42:29 AM CST
Brother_MFC-7340 accepting requests since Fri 06 Dec 2013 04:11:28 PM CST
MFC-7340 accepting requests since Fri 06 Dec 2013 04:11:28 PM CST
MFC7340 accepting requests since Fri 06 Dec 2013 04:11:28 PM CST
printer BRFAX is idle.  enabled since Tue 03 Dec 2013 10:42:29 AM CST
   File "/usr/lib/cups/filter/brfaxfilter" has insecure permissions (0100777/uid=0/gid=0).
printer Brother_MFC-7340 disabled since Fri 06 Dec 2013 04:11:28 PM CST -
   Unplugged or turned off
printer MFC-7340 disabled since Fri 06 Dec 2013 04:11:28 PM CST -
   Unplugged or turned off
printer MFC7340 disabled since Fri 06 Dec 2013 04:11:28 PM CST -
   Unplugged or turned off
Brother_MFC-7340-14     jnankin          77824   Tue 10 Dec 2013 06:46:52 PM CST
Brother_MFC-7340-15     jnankin         305152   Tue 10 Dec 2013 07:30:13 PM CST

我如何讓 lpstat 為這項工作列印“待定”或等價物?同樣,如果我有作業字元串,我如何查看作業是完成還是失敗(在本例中為 Brother_MFC-7340-15)

man lpstat

將顯示很多東西:

-t                    Prints all  status  information.  This
                     includes  all the information obtained

對於狀態隊列,您可以嘗試使用:

-W display the status of all print queues in wide format

或者

-p -l 將顯示長的工作列表。

“lpq”對於列印機作業隊列資訊也很有用。

好…

lpstat -W completed顯示已完成的作業。

lpstat -W completed printerName顯示列印機“printerName”的已完成作業

lpstat 命令預設顯示未完成(待定)的作業…

lpstat:錯誤 - 在“-W”選項之後需要“完成”、“未完成”或“全部”!

所以有一種方法可以按摩命令選項來獲得你需要的東西。僅查看http://your.ip:631上的本地 CUPS Web 界面會不會更容易- 因為這將提供更多實時狀態?

引用自:https://serverfault.com/questions/560559