Script list-all-printers

Escribí el script list-all-printers para obtener, en línea de comandos, la lista de impresoras configuradas en el equipo, indicando cuál de ellas es la impresora por defecto.

#!/bin/bash
# ------------------------------------------------------------
# script:  /usr/local/sbin/list-all-printers
# Author:  Esteban M. Navas Martín
# Date:    06-09-2019
# Ver:     07-09-2019
#
# Purpose: List all configured printers

# Copyright (c) 2019 Esteban M. Navas Martín . All rights reserved.
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.

#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#   You should have received a copy of the GNU General Public License
#   along with this program. If not, see .

default=$(LC_ALL=C.UTF-8 lpstat -d | awk '{print $4}')

echo "Impresoras configuradas en `hostname`:"

for printer in `LC_ALL=C.UTF-8 lpstat -p | awk '{print $2}'`; do

    if [ "$printer" = "$default" ]; then
       echo "* $printer (impresora por defecto)"
    else
       echo "* $printer"
    fi
done

A continuación podemos ver un ejemplo de ejecución del script:

list-all-printers 
Impresoras configuradas en sprofesores-pro:
* Copiadora_BN
* sprofesores-lpr (impresora por defecto)
Be the first to comment

Por favor acceder para comentar.