[Samba] Samba printer management commands

Juan Asensio Sánchez okelet at gmail.com
Thu Dec 16 02:15:15 MST 2010


Hi

I am trying to setup remote printer management commands, so the users
could add and delete printers from "Printers" share of Samba in
Windows. I have this script, that is launched using an administrator
account, when I add a printer from there, using a new TCP/IP port:

================================================================

#!/bin/bash

{

	##########################################################################
	# Parámetros
	##########################################################################
	
	# Nombre de la impresora
	LPNAME=$(echo "$1" | iconv -t ascii//translit | sed --regexp-extended
's/\s+/_/g')

	# Nombre del recurso compartido
	SHARENAME=$2
	
	# Nombre del puerto
	PORTNAME=$3
	
	# Nombre del controlador
	DRIVERNAME=$4
	
	# Localización
	LOCATION_OLD=$5

	# Localización en Windows 95
	LOCATIONWIN9X=$6

	# Comprobar la sintaxis de la localización, y añadir el protocolo por
defecto si no lo tiene
	if [[ ! ${LOCATION_OLD} =~ ":/" ]]
	then
		LOCATION_NEW="lpd://${LOCATION_OLD}"
	else
		LOCATION_NEW="${LOCATION_OLD}"
	fi

	# Mostrar mensaje
	echo "Añadiendo impresora. Nombre: $1 (${LPNAME}); recurso:
${SHARENAME}; puerto: ${PORTNAME}; driver: ${DRIVERNAME};
localización: ${LOCATION_OLD} (${LOCATION_NEW}); localización Win9X:
${LOCATIONWIN9X}..."

	# Añadir la impresora
	/usr/sbin/lpadmin -p "${SHARENAME}" -D "${DRIVERNAME}" -E -v "${LOCATION_NEW}"


	# Recargar la configuración de Samba
	/etc/init.d/smb reload

} 2>&1 | logger -t SMB_PRINTER_ADD

================================================================

The printer is recognized correctly in the wizard, but when I press
the Finish button, i get ever "Access denied", although the printer
has been created correctly in /etc/printcap. What am I doing wrong?

Regards.


More information about the samba mailing list