Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to display printer information, such as printer description or printer location using command line tools?

lpstat -t lists printer names, classes and devices for printers, but it doesn't list printer description or location. Is there a way to get this information without using http or GUI interface?

share|improve this question
up vote 3 down vote accepted

You can obtain this information with lpstat -l -p printername.

[root@Valley ~]# lpstat -l -p zebra2
printer zebra2 is idle.  enabled since Tue Jun  8 15:50:35 2010
        Form mounted:
        Content types: any
        Printer types: unknown
        Description: Zebra 105SL in shipping
        Alerts: none
        Location: Shipping
        Connection: direct
        On fault: no alert
        After fault: continue
        Users allowed:
                (all)
        Forms allowed:
                (none)
        Banner required
        Charset sets:
                (none)
        Default pitch:
        Default page size:
        Default port settings:
share|improve this answer
    
Thanks, this helps. Do you know if the returned field names are locale aware, or will they always default to English? – QZ Support Mar 22 at 17:25
    
I do not know, but you can check at cups.org and with your specific distribution of Linux. – ewwhite Mar 22 at 17:26
    
Turns out it is. Exporting LANG=C does the trick to force en_US. If calling this command with Apple, an additional export SOFTWARE= (blank) needs to be provided to bypass the locale used by the desktop. Why mention this? If you are parsing the output of this command wight a script (e.g. grep "Description:"), forcing locale is a good idea, or else the logic could fail on a non-English desktop/terminal. – QZ Support Apr 20 at 2:34

This is a bit more global, for everything eliminate the grep statement.

for i in $( lpstat -v | awk '{ print $3 }' | tr ':' ' ' ) ; do lpstat -l -p $i | grep 'printer\|Location' ; done
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.