Technical article 125058

How do I print from OpenServer to a printer attached to a Windows system using Samba 2.x?

OpenServer 5.0.5OpenServer 5.0.6OpenServer 5.0.7

Written · Last revised

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 print
server=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/smbprint

Substitute the UNIXPRINTER with the name you want to give to the printer.

Then modify the interface script in
/usr/spool/lp/admins/lp/interfaces/UNIXPRINTER
Change 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 UNIXPRINTER

Now 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."

From the Xinuos technical article database, record 125058. Reproduced with permission. The original is at www.sco.com/ta/125058, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.