1 Replies - 118 Views - Last Post: 16 February 2019 - 10:23 AM

#1 mercy_angel   User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 444
  • Joined: 28-February 13

Get a printer name into variable with similar printers

Posted 16 February 2019 - 09:46 AM

I am using a same printer vendor for 2 printer. Some of them dont have just default name with a full name of that printer.

for example
# lpstat -a | awk '{print $1}'|grep CITIZEN
CITIZEN
CITIZEN-T-S851II


This first one CITIZEN is a part of script
if grep -q S310II /etc/cups/printers.conf; then
PRINTER="$(lpstat -a | awk '{print $1}'|grep S310II)"

But this gave me nothing, so first lines are good, it find a S310II because of cups info, but NAME is not s310, just CITIZEN. So i Can change S310II to just CITIZEN, because you see first code i posted, what gave me, two CITIZEN.
How can I just get a printer name for that S310II. This script is helped me so much, but now with this similar names are a bit strange to get it.

Is This A Good Question/Topic? 0
  • +

Replies To: Get a printer name into variable with similar printers

#2 mercy_angel   User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 444
  • Joined: 28-February 13

Re: Get a printer name into variable with similar printers

Posted 16 February 2019 - 10:23 AM

if grep -q S310II /etc/cups/printers.conf; then
PRINTER="$(grep -B 5 CT-S310II /etc/cups/printers.conf | head -1 | cut -d "<" -f2 | cut -d ">" -f1 | awk -F " " '{print $2}')"


this is how I solve it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1