Getting Down to Business
Uh oh. Something didn’t work right for you? It’s time to get your hands dirty learning how to troubleshoot. This section will assist you in troubleshooting your basic GhostScript and AppleTalk, SAMBA, or TCP/IP installations. It will not cover much of anything related to settings for GhostScript or your particular printer
What this section will cover:
- Making sure that GhostScript works.
- Making sure that your network connection works (LPD, AppleTalk, or SMB)
- Making sure that your lpd.filter works.
- Making sure that Mac OS X is actually executing the lpd.filter file.
If all of the above are working, you should be able to get your printer working. However, because I don’t know everything about every possible printer, we will not cover the following in this section:
- How to choose the correct GhostScript driver for your particular make and model of printer.
- How to use any of the advanced GhostScript parameters.
- Pretty much anything that’s not mentioned in the first list, above.
Many specific questions about the smaller details, such as choosing drivers, using Uniprint or gimp-print, and so on can be found at http://www.linuxfoundation.org/collaborate/workgroups/openprinting.
That said, let’s begin.
Note: in the examples below, you won’t have to be root user. The examples reference your ~ (home) folder for accessing certain files. Note that if you su or sudo to root, references to ~ now refer to the root user’s home folder, which is not necessarily your own home folder. If you’ve become root, you can use the exit command to become yourself again.
Ensure that GhostScript Works
Let’s make sure that GhostScript works by turning a directory listing into a JPG file that you can look at in the Mac OS X Preview application. Then we’ll know that GhostScript is working properly. Do the following in the terminal:
- cd ~
- Puts you in your home directory. This is the directory listing we’re going to turn into a JPG.
- ll | enscript -o test.ps
- Feed the output of the ll command (a directory listing) to the enscript command, which will turn it into a Postscript file named test.ps, which will be located at the root level of your home directory. Note that the | is the pipe (vertical bar) symbol, which is located above the Return key on U.S. keyboards. We’re doing this step to generate a quick-and-dirty Postscript file. Unfortunately the Preview application seems to have forgotten its Mac/NextStep roots, and won’t open Postscript files, but if you have Illustrator or another program that will open Postscript files, feel free to verify that we’ve generated good PostScript.
- gs -q -dBATCH -sDEVICE=jpeg -sOutputFile=test.jpg test.ps
- Convert the Postscript file test.ps to a JPG called test.jpg. You now have a Unix directory listing that you can now open in the Preview application.
If the above trick worked for you, you can be assured that GhostScript is functioning properly on your system. If it failed, GhostScript is obviously not working, and you’ll have the unpleasant duty of trying to figure out why. It’s possible you may have already had GhostScript installed and they’re conflicting.
Ensure that your LPD Network Connection Works
If you’re trying to print to an LPD (TCP/IP) printer, this step will use the terminal to ensure that you have basic access to your LPD system, i.e., that is can spool jobs to your printer.
I highly recommend that you generate a test file from Windows for your specific printer, so that you can eliminate GhostScript driver problems, or use one of the pcl files from the balthisarfiles.sit package in the LanguageSamples folder. Using a known, good printer language file will assure you that not only does the LPD system spool, but that it spools correctly.
The following instructions assume you’ve setup your printer lp in NetInfo, and that you have a printer image file called test.pcl for your printer in your home directory. Feel free to change the path and filename as you see fit to access your own sample printer file.
- lpr -v -h -Plp ~/test.pcl
- Print the file test.pcl from your home directory via the printer lp, as defined in NetInfo.
If your printer spit out something, you can be pretty confident that LPD is running and working properly. If you got garbage from the printer, then that’s a start. You’ll have to decide if your printer test file isn’t perfect for the printer, or if your printer server is having issues.
If nothing came out of the printer at all, it’s likely that LPD isn’t running, or that your lp printer definition in NetInfo isn’t correct. You can ensure the LPD is running by typing /usr/libexec/lpd as root in the terminal, or simply restart your computer.
Ensure that your AppleTalk Network Connection Works
To ensure that your AppleTalk connection works, simply repeat the An Interesting Experiment section.
Ensure that your SMB Network Connection Works
Repeat the Ensure that your LPD Network Connection Works instructions, above, but use the following command to spool to your printer via SAMBA:
- test.pcl | smbclient '\\WINBOX\windeskjet' -P -N -c 'print -'
- Print the file test.pcl via SAMBA.
Ensure that your lpd.filter File Works
Assuming all of the above work, you can test your lpd.filter file so:
- cd /usr/local/lib/lpd
- Move to the lpd directory where the lpd.filter resides.
- test.ps | ./lpd.filter
- Send an arbitrary Postscript file (e.g., the one you generated above) to your lpd.filter file. Assuming your GhostScript works as above, and your printer is accessible, the filter should work and do something.
Note: if your lpd.filter doesn’t work here, and you know that GhostScript works and that your network connection to the printer works, then there is a problem with the filter. Double- and triple-check your work in the filter, especially quotation marks and nested quotation marks or escaped characters.
Note: some people report that their Stuffit Expander automatically translates the Unix end-of-line characters to Macintosh end-of-line characters. This is Expander trying to do you a favor and making the file “Macintosh compatible,” but for our purposes it’s a nuisance. Try adjusting your preferences so this doesn’t happen when you unstuff the balthisarfiles.sit package. Alternatively you can use a program such as Bare Bones’ TextWrangler or BBEdit to automatically transform end-of-line characters between Macintosh, Windows, and Unix end-of-line characters. The last option is using pico and erasing every end of line character, and putting them back in yourself — that’s bound to be time consuming, though.
Ensure that Mac OS X is Executing the lpd.filter File
Finally, we know that GhostScript works, your network connection to the printer works, and that everything works together in the filter. Hence, if the Mac OS is successfully executing the filter file, lpd.filter, then it stands to reason that your complete setup should work.
If you put this line…
echo Filter Executed > ~username/filterrun.txt
…into the very top of your lpd.filter file, where ~username is the user whose home folder you’d like to use for the experiment, you can verify that when printing from Mac OS X your lpd.filter file is truly executed. For example, if you attempt to print, and nothing happens, you can look in username’s home folder, and see if the file filterrun.txt exists. If it does, you can be assured that the Mac OS is successfully executing the filter.
You should be sure to put the line at the top of the file in order to ensure that the filter is being executed. If you were to put the line somewhere else, there’d be a chance that an error in the file would prevent the echo command from running, and you’d falsely believe that your filter wasn’t running.
So what happens if the filter doesn’t run? Well, chances are that your permissions aren’t correct. Make sure you go back over the preceding chapters and repeat the chown commands so that you have proper permissions in all of the relevant spots.
If your filter is working but you don’t get any output, I would recommend that you make sure your files are being spooled — check out the appropriate spool directory you created in Build Our Spool Directories, and see if new files are showing up when you print. If not, the lpd.filter is probably broken somewhere. Repeat this chapter to double-check. It’s also possible that your printer or print server just isn’t accepting the jobs.
Finally, check out the Mac OS X Console application to see if anything relevant shows up there.