Problem
I have a printer attached to a Windows system and I wish to print to it from OpenServer. I have already installed and configured Samba 2.x on this OpenServer system, but wish to configure this remote printer for printing.
Solution
First the Printer must be configured and shared from the Windows side. Verify that the printer can print from Windows prior to attempting to print to it from OpenServer.
Use the following interface script and store it in
/usr/lib/samba/bin/smbprint:
----------------------cut here----------------------#!/bin/sh
#
# @(#) smbprint.sysv version 1.0 Ross Wakelin <r.wakelin@march.co.uk>
#
# Version 1.0 13 January 1995
# modified from the original smbprint (bsd) script
#
# this script is a System 5 printer interface script. It
# uses the smbclient program to print the file to the specified smb-based
# server and service.
#
# To add this to your lp system, copy this file into your samba directory
# (the example here is /usr/lib/samba/bin/),
# modify the server and service variables and then execute the following
# command (as root)
#
# /usr/lib/lpadmin -punixprintername -v/dev/null -i/usr/lib/samba/bin/smbprint
#
# where unixprintername is the name that the printer will be known as
# on your unix box.
#
# the script smbprint will be copied into your printer administration
# directory (/usr/lib/lp or /etc/lp) as a new interface
# (interface/unixprintername)
# Then you have to enable unixprintername and accept unixprintername
#
# This script will then be called by the lp service to print the files
# This script will have 6 or more parameters passed to it by the lp service.
# The first five will contain details of the print job, who queued it etc,
# while parameters 6 onwards are a list of files to print. We just
# cat these at the samba client.
#
# Set these to the server and service you wish to print to
# In this example I have a WfWg PC called "lapland" that has a printer
# exported called "printer" with no password.
#
# clear out the unwanted parameters
shift;shift;shift;shift;shift
# now the argument list is just the files to printserver=NETBIOSNAME
service=PRINTERNAME
account=PRINTUSER
password=PRINTPASSWORD
#logfile=/dev/null
logfile=/var/log/samba.d/log.`basename $0`(
# NOTE You may wish to add the line `echo translate' if you want automatic
# CR/LF translation when printing.
echo $password
echo translate
echo "print -"
cat $*
) | /usr/lib/samba/bin/smbclient "\\\\$server\\$service" -U $account -P >$logfile
2>&1
exit $?
----------------------cut here----------------------Add the printer into the spooler using the command:
/usr/lib/lpadmin -pUNIXPRINTER -v/dev/null -i/usr/lib/samba/bin/smbprintSubstitute the UNIXPRINTER with the name you want to give to the printer.
Then modify the interface script in
/usr/spool/lp/admins/lp/interfaces/UNIXPRINTERChange the values for NETBIOSNAME with the name of the Windows system
that has the printer shared and PRINTERNAME with the name the printer
is shared as. Replace PRINTUSER with the name of an account that is
allowed to use this printer and PRINTPASSWORD with that user's
password. Save the file.Enable the printer to accept requests with the commands:
enable UNIXPRINTER
accept UNIXPRINTERNow from the OpenServer command line, print jobs can be sent to this Windows printer by issuing standard lp commands: "lp -d UNIXPRINTER file"
See also
TA119726 - "OSR507:How do I configure Samba 2.2.6c on my OpenServer server?"
TA114822 - "How do I download, compile and install the latest version of SAMBA for OpenServer?"
TA127012 - "How can I print from a UnixWare 7.1.4, OpenServer 6.0.0/5.0.7 server running Samba 3 to a Windows shared printer?
TA126741 - "I can't print from a SCO Unix box running Samba 3.0.X to a Windows XP shared printer."