Getting Down to Business

Use the Terminal to Build the Filter

File Needed! In this step, you’ll need to have downloaded balthisarfiles.sit, and then unstuffed it in a location that’s known and accessible to you. You’ll be using it very shortly, below.

The next thing we need to do is put our filter files where the print system expects to find them. Start a terminal, su to root, and type these:

mkdir –p /usr/local/lib/lpd
creates the directory we need.
cd /usr/local/lib/lpd
puts you in the OS’ lpd directory.
cp …path…/lpd.filter lpd.filter
copies the lpd.filter file.
cp …path…/GhostScript.ppd GhostScript.ppd
copies the GhostScript.ppd file.
cp …path…/endofjob endofjob
copies the endofjob file.
cd ..
backs up one directory level.
chown -R root.daemon lpd
sets the proper permissions for this directory.
mkdir –p /usr/local/lib/lpd
creates the directory we need.
cd /usr/local/lib/lpd
puts you in the OS’ lpd directory.
cp …path…/lpd.filter lpd.filter
copies the lpd.filter file.
cp …path…/GhostScript.ppd GhostScript.ppd
copies the GhostScript.ppd file.
cp …path…/endofjob endofjob
copies the endofjob file.
cd ..
backs up one directory level.
chown -R root.daemon lpd
sets the proper permissions for this directory.

Note: you need to know the path to the files you’re copying above. For example, had I unstuffed the file in the “Downloads” folder in my own home directory, then the …path… portion of the cp command I would use would be ~jderry/Downloads/balthisarfiles/Filter.

Now that the files are in place, we need to edit the file to make it useful. Type:

cd lpd
go back to the lpd directory, since we had just backed out of it.
pico lpd.filter
opens lpd.filter file in pico.

Great, you should now be in the pico editor looking at the lpd.filter file. The actual file you’ll see has a lot more information in it, buried in comments, but these have been left out below for conciseness. Please read through the whole file for some added ideas.

#!/bin/sh
#--------------------------------------------------------------------
# Setup our local variables - note: if you have another version
# of GhostScript, these paths MAY be different. For example,
# the fink package manager installs into /sw instead of /usr/local.
# If you're using another distribution of SAMBA for SMB printing,
# note the SMBPATH may be different on your machine, too!
#--------------------------------------------------------------------
GS=/usr/local/bin/gs
GS_FONTPATH=/usr/local/share/ghostscript/fonts:/usr/local/share/ghostscript/6.50/lib
SMBPATH=/usr/local/samba/bin/smbclient
export GS GS_FONTPATH SMBPATH

#--------------------------------------------------------------------
# NON-APPLETALK Printers: remove the comment from the line below:
#--------------------------------------------------------------------
 -dNOPAUSE -q -dBATCH -sDEVICE=cdj550 -r600 -sOutputFile=\|"/usr/bin/lpr -v -h -Plp" -

#--------------------------------------------------------------------
# APPLETALK Printers: remove the comment from the line below:
#--------------------------------------------------------------------
 -dNOPAUSE -q -dBATCH -sDEVICE=cdj550 -r600 -sOutputFile=\|"/usr/bin/atprint deskjet970:DeskWriter" -

#--------------------------------------------------------------------
# SAMBA Printers: remove the comment from the line below:
#--------------------------------------------------------------------
 -dNOPAUSE -q -dBATCH -sDEVICE=cdj550 -r600 -sOutputFile=- - | $SMBPATH '\\WINBOX\windeskjet' -P -N -c 'print -'

Note: If you installed your own version of GhostScript, make sure the GS and the GS_FONTPATH lines contain the correct directory paths. If you installed my recommended distribution, then you’re already okay.

Note: If you installed your own version of SAMBA, make sure the SMBPATH line contains the correct directory path. If you installed my recommended distribution, then you’re already okay. And of course, if you’re not printing to an SMB device, don’t worry about it.

Let us concentrate on the last three “major sections” of the file. The filter as-is will do nothing until we remove one of the comment symbols. Depending on your printing method, do one of the following:

  • TCP/IP using the LPD system:
    • Remove the comment symbol from the $GS line in the NON–APPLETALK section.
  • AppleTalk:
    • Remove the comment from the $GS line in the APPLETALK section.
    • Replace deskjet970:DeskWriter with the AppleTalk name and type pair that you learned in the An Interesting Experiment section of this guide.
    • If your printer name or type has a space in it, see note below.
  • SMB via SAMBA:
    • Remove the comment from the $GS line in the SAMBA section.
    • Replace \\WINBOX\windeskjet with:
      • the name of the Windows computer hosting the printer in place of WINBOX.
      • the name of the printer as shared by the Windows computer in place of windeskjet.
    • If your SMB printer requires special access, such as a different Workgroup or the use of user name and password, see note below.

    When you’re done making the necessary changes, type Ctrl-O, hit Return, and type Ctrl-X to exit from pico.

AppleTalk Note: remember your printer name from An Interesting Experiment, above? If your printer name has a space in it, you’ll have to nest the quotes. For example, if your printer is called deskjet 970 instead of deskjet970, you’ll have to write the printer name/type like this, for example:

'deskjet 970':DeskWriter

Your complete –sOutputFile= parameter will look something like this with nested quotes:

\|"/usr/bin/atprint 'deskjet970':DeskWriter"

SMB Note: SAMBA is able to support Windows’ Workgroups as well as user-authentification. If you require this type of access, please consult man smbclient from the terminal or from the internet.

Note: Don’t forget the single hyphen at the end of the line. It’s not shown in this example, because it’s a parameter of its own, but easy to overlook. It’s located on the $GS line where we would normally supply a file name for GhostScript processing. But when Mac OS X passes in the Postscript file it generates, it can have any old name and could potentially be anywhere on the hard drive. Use of the hyphen is a standard Unix convention to represent the name and path of whatever file is passed in – in this case, the Postscript file generated by Mac OS X.