Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Aug 1997 08:16:18 -0700
From:      "M.R.Murphy" <mrm@Mole.ORG>
To:        bdodson@beowulf.utmb.edu, questions@FreeBSD.ORG, shawn@cpl.net
Subject:   Re: Printing on Hp Deskjet 855C
Message-ID:  <199708131516.IAA08152@meerkat.mole.org>

next in thread | raw e-mail | index | archive | help
>
>
> > 
> > Is it possible to print using lpr(smbclient works) to a HP Deskjet 855C?
>
> Yes (assuming it is connected to a microsloth box).

Agreed.

>
> > Would I be better off
> > connecting the printer to the FreeBSD box and share it with Samba? 
>
> Yes.

No :-)

Better, I think, to connect the printer to the uSoft box, share it, and
use smbclient from lpd to print. That way you get all of the niceties
that HP has included in the printer driver for uSoft (like using the
sound card to emote "You're out of paper." uSoft Win95 boxes make
wonderful little print servers :-)

>
> >If
> > its possible and anyone has
> > a printcap for this printer that works id appreciate it if you could
> > pass it along.


# printcap for HP-laserjet on Win95 and an Epson Stylus Color 500 on

# HP LaserJet 4L on Win95
lp|samba line printer HP-Laserjet:\
        :lp=/dev/null:lf=/var/log/lpd-errs:sh:mx#0:\
        :if=/usr/local/samba/bin/smbprint:\
        :sd=/var/spool/lpd/lp:\
        :af=/var/spool/lpd/lp/acct

# Epson Stylus Color 500 on Win95
ep|samba line printer Epson:\
        :lp=/dev/null:lf=/var/log/lpd-errs:sh:mx#0:\
        :if=/usr/local/samba/bin/smbprint:\
        :sd=/var/spool/lpd/ep:\
        :af=/var/spool/lpd/ep/acct


I like this smbprint a little better than that which came out of the
box with Samba:

---------8<---------
#!/bin/sh -x

PATH=/usr/local/bin:/usr/local/samba/bin:/bin:/usr/bin export PATH

# This script is an input filter for printcap printing on a unix machine. It
# uses the smbclient program to print the file to the specified smb-based 
# server and service.
# For example you could have a printcap entry like this
#
# smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
#
# which would create a unix printer called "smb" that will print via this 
# script. You will need to create the spool directory /usr/spool/smb with
# appropriate permissions and ownerships for your system.

# 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.

#
# Script further altered by hamiltom@ecnz.co.nz (Michael Hamilton)
# so that the server, service, and password can be read from 
# a /usr/var/spool/lpd/PRINTNAME/.config file.
#
# In order for this to work the /etc/printcap entry must include an 
# accounting file (af=...):
#
#   cdcolour:\
#	:cm=CD IBM Colorjet on 6th:\
#	:sd=/var/spool/lpd/cdcolour:\
#	:af=/var/spool/lpd/cdcolour/acct:\
#	:if=/usr/local/etc/smbprint:\
#	:mx=0:\
#	:lp=/dev/null:
#
# The /usr/var/spool/lpd/PRINTNAME/.config file should contain:
#   server=PC_SERVER
#   service=PR_SHARENAME
#   password="password"
#   translate={yes|no}
#   psDevice=DEVICE_FOR_GS
#   psOptions=OPTIONS_FOR_GS
#
# E.g.
#   server=PAULS_PC
#   service=CJET_371
#   password=""
#   translate=yes
#   psDevice=ljet4
#   psOptions=-r300x300

#
# Debugging log file, change to /dev/null if you like.
#
# logfile=/tmp/smb-print.log
logfile=/dev/null


#
# The last parameter to the filter is the accounting file name.
#   Extract the directory name from the file name.
#   Concat this with /.config to get the config file.
#
eval acct_file=\$$#
spool_dir=`dirname $acct_file` 
config_file=$spool_dir/.config

# Should read the following variables set in the config file:
#   server
#   service
#   password
#   psDevice
#   psOptions
#   translate
eval `cat $config_file`

# Save the input file in a temporary
umask 007
inFile=/tmp/$$.inFile
ouFile=/tmp/$$.ouFile
trap "rm -f $inFile $ouFile; exit;" 0 1 2 3 15
cat - > $inFile

fileType=`file $inFile`
case "$fileType" in
*PostScript*)
  echo quit|gs -q -dNOPAUSE -sDEVICE=$psDevice $psOptions -sOutputFile=$ouFile $inFile >> $logfile 2>&1
  File=$ouFile
  translate=no
  ;;
*)
  File=$inFile
  ;;
esac

export File inFile ouFile

#
# Some debugging help, change the >> to > if you want to save space.
#
echo "server $server, service $service, psDevice $psDevice, translate $translate, inFile $inFile, ouFile $ouFile, File $File" >> $logfile
ls -l $File $inFile $ouFile >> $logfile


(
# NOTE You may wish to add the line `echo translate' if you want automatic
# CR/LF translation when printing.
#       echo translate
	[ x"$translate" = xyes ] && echo translate
	echo "print -"
	cat $File
) | smbclient "\\\\$server\\$service" $password -U $server -N -P >> $logfile

---------8<---------

Here's the .config for the Epson:

server=redreed
service=EPSON
password=""
translate=yes
psDevice=stcolor
psOptions=-r360x360


and for the HP:

server=popcorn
service=HP
password=""
translate=yes
psDevice=ljet4
psOptions=-r300x300



This ends up being a pretty gentle printing system.

--
Mike Murphy  mrm@Mole.ORG  +1 619 598 5874
Better is the enemy of Good



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199708131516.IAA08152>