Script remove-all-printers

El script remove-all-printers me permite eliminar desde la línea de comandos, todas las impresoras que tenga configurado el equipo:

#!/bin/bash
# ------------------------------------------------------------
# script:  /usr/local/sbin/remove-all-printers
# Author:  Esteban M. Navas Martín
# Date:    06-09-2019
# Ver:     07-09-2019
#
# Purpose: Remove 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 .

for printer in `LC_ALL=C.UTF-8 lpstat -p | awk '{print $2}'`; do
   lpadmin -x $printer
   echo "Impresora $printer eliminada"
done

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

remove-all-printers 
Impresora Copiadora_BN eliminada
Impresora sprofesores-lpr eliminada

Si volvemos a ejecutar el script por segunda vez, veremos que ya no tenemos impresoras configuradas en el sistema:

remove-all-printers 
lpstat: No destinations added.
Be the first to comment

Por favor acceder para comentar.