Difference between revisions of "Setting up Network Printer Ports"

From SambaWiki
m (Mmuehlfeld moved page Network Printer Ports to Configure network printer ports: Rename page for better wiki structure)
Line 19: Line 19:
 
echo "DemoPrinter3"
 
echo "DemoPrinter3"
 
:Of course you don't have to simply „echo“ these entries. They can be retrieved from other sources and printed, too.
 
:Of course you don't have to simply „echo“ these entries. They can be retrieved from other sources and printed, too.
  +
:By adding echo "Samba Printer Port" to the above script, you wont lose the previous settings, just make sure you echo it once.
   
 
* Make the script executable
 
* Make the script executable
Line 31: Line 32:
 
* The port entries generated by the script are visable and selectable in the printers properties on the print server (e. g. via printmanagement.msc).
 
* The port entries generated by the script are visable and selectable in the printers properties on the print server (e. g. via printmanagement.msc).
 
:[[Image:Printer_Ports.png]]
 
:[[Image:Printer_Ports.png]]
 
 
 
 
   
 
= Additional Notes =
 
= Additional Notes =

Revision as of 14:45, 5 July 2016

Introduction

The concept of a "port" is fairly foreign to UNIX hosts. Under Windows print servers, a port is associated with a port monitor and generally takes the form of a local port (i.e. LPT1:, COM1:, FILE:) or a remote port (i.e. LPD Port Monitor, etc...). By default, Samba has only one port defined "Samba Printer Port". Under Windows, all printers must have a valid port name.

Usually you don't have to change this behaviour. But in some situations, it might be necessary, like when Windows drivers try to send SNMP requests or automatic driver configuration requests towards to the printer.

If you wish to have a list of ports displayed (smbd does not use a port name for anything) other than the default "Samba Printer Port", you can define enumports command to point to a program/script which should generate a list of ports, one per line, to standard output. This listing will then be used in response to the level 1 and 2 EnumPorts() RPC.



Setup Printer Ports

  • Write a script (e. g. /usr/local/bin/show-ports.sh), that prints the name/IPs of the printers, one per line, to standard output:
#!/bin/bash
echo "DemoPrinter1"
echo "DemoPrinter2"
echo "DemoPrinter3"
Of course you don't have to simply „echo“ these entries. They can be retrieved from other sources and printed, too.
By adding echo "Samba Printer Port" to the above script, you wont lose the previous settings, just make sure you echo it once.
  • Make the script executable
chmod 755 /usr/local/bin/show-ports.sh
  • Add the following line to the [global] section of your smb.conf:
enumports command = /usr/local/bin/show-ports.sh
  • Reload Samba
# smbcontrol all reload-config
  • The port entries generated by the script are visable and selectable in the printers properties on the print server (e. g. via printmanagement.msc).
Printer Ports.png

Additional Notes

  • Changes done afterwards in the script doesn't require reloading Samba.
  • If a port, associated with a printer, changes afterwards in the scripts output, will cause loosing this association!