Have a Question?
Print

00230: Troubleshooting printer problems under Unix

Title:

Troubleshooting printer problems under Unix

Description:

When troubleshooting printer problems, check the cable configuration, operating system configuration, and spooler configuration before attempting to use BBx using the guidelines outlined. 


Resolution:

1. First, determine if the computer is talking to the printer. When running under the Unix operating system, you should know the physical port where your printer is connected. For example, it may be tty1a, tty010, tty0p1, etc. Once the port has been determined, you can test the connection by “cat”-ing a file (like /etc/passwd) to the port. The command line would look like this: 

$ cat /etc/passwd > /dev/tty??? 
        where the question marks are the port name. 

2. If you still do not receive any response form your printer, check the cable configuration. (Try swapping pins two and three.) Verify that you are indeed physically connected to the port. Often it is helpful to reset the printer between tests by turning it off and back on. Some printers refuse to communicate if they’ve been sent a confusing sequence of characters via a bad cable, and they must be reset. 

3. If you are certain that the computer is talking to the printer (i.e., something at least semi-understandable printed when you sent a file to the port), the next step is to decide whether or not the communications parameters are set properly between the printer and the computer. If something printed, but it was very strange looking with garbage characters, check the communications parameters of the printer and compare them with the parameters set on the port at the computer’s end. Again, the command for most systems would be: 

$ stty -a < /dev/tty??? 

For baud rate, look for a number in the first line of the output of this command. For example, 9600, 1200, or 300. exta and extb denote 19200 and 38400 baud respectively. If the parameters don’t match, you should make a decision. Do you want BBx to send output directly to the port? If you do, then you will need to set the baud rate yourself. Read the paragraphs below about sending output directly to a port. If you want BBx to send output through the system spooler, then read the section below on using the system spooler. Either way, the communication parameters should be set properly. 

Other than baud rate, you should look at word size, parity, and number of stop bits. Make sure that the printer receives what it is expecting. Use the stty command to view the current settings of the port. Then use “openport” (recommended for direct printers) or the spooler interface file to set them correctly. If your printer received half a page or so and then either hung up or began to go absolutely crazy, check the xon, xoff parameters. Use stty to find out whether or not these are set (ixon, ixoff). 

Sending Output Directly to a Port: 

Under the Unix operating system there are some caveats to sending output directly through the port to a serial printer. First, BBx assumes nothing. If you want to use different communications parameters, you must make the appropriate adjustments to these settings. Also, other programs (such as the system spooler) which use the same serial port will not necessarily know that BBx is sending output at a given moment, and you may get several reports which are tossed together haphazardly. Let’s use the following alias line as an example: 

alias P3 /dev/tty011 “Super Line Printer” CR 

If you’ve checked the stty settings on /dev/tty011 and the baud rate or other communication parameter needs to be adjusted to match the printer, try using the “openport” shell script included with the BBx distribution. Read the script file first. It is meant as a generic script which runs in the background and continually sets certain parameters on a serial port. You can start it up every day by moving it to your /etc directory and entering the command in your startup file. Starting “openport” should alleviate any symptoms of bad communications between BBx and your printer. 

If you are printing to BBxPROGRESSION/4 and someone else decides to print from another software program that uses the same printer port via the spooler, then add a LOCK=/path/filename to your printer alias. This causes BBx to create the lock file whenever a user opens the printer. The lock file is erased when the printer is closed. Some Unix operating system spoolers use a similar locking scheme. Make sure that your lock file name is the same name as your Unix operating system spooler lock file name. Some versions of Unix operating system spoolers don’t use lock files in this manner. Check the Libraries in the BASIS forum on CompuServe for a copy of a script file chklck. The spooler interface file can invoke this script file to check for the existence of a BBx lock file. 

Just as a combination lock is worthless if the combination is given to everyone you know, a lock file, too, can be totally useless in some conditions. If your users run as “root” or superuser (UID 0), the lock file will not work. If BBx itself is running as superuser via the “Set UID” bit, the lock file will not work. 

Sending Output Through the System Spooler: 

Assuming that you’ve already verified that in some meaningful way the computer and printer are communicating, you may decide to use BBx to send output to the printer via the system spooler. Using the spooler is a tidier way to access the printer, but can cause problems if you print forms and align forms on line. Take a look at this example of an alias line which uses the Unix operating system spooler: 

alias LP “> lp -s -dhplaser 2>/dev/null” “Spooler” CR 

When your user tries to open LP, BBx opens a pipe to the Unix operating system spool command lp. In some cases, the command might be lpd or lpr. Check your Unix operating system manual for details. This method of BBx printer access assumes the Unix operating system spooler has been configured. 

The spooler program must know about the printer. Also, it must know the same things that BBx would have to know when talking to the port directly. Make sure the spooler is working at the operating system level before attempting to configure BBx to use the spooler. Refer to your Unix operating system spooling documentation for the proper method of setting up the spooled printer. 

Try lpinit or lpadmin to add printer definitions to your spooling system. When you add a printer, you give it a logical name, “hplaser” in the above example. This is known as a destination. After you’ve configured the printer to the spooler, an interface file is created. This file is simply a Unix operating system script file that sends your output to the physical port, after it makes certain that the communication parameters (discussed above) are properly set. Again, check the Unix operating system spooling documentation. On SCO Xenix, look in the directory /usr/spool/lp/interface for the interface file that corresponds to your printer. In this example, it would be named “hplaser”. In some cases, it may be desirable to edit the interface file to send extra stty parameters such as ixon, ixoff, onlcr, etc., before sending output to the port. 

To analyze how BBx uses the spooler, look again at the alias line above. Everything which appears within the first set of double quote marks with the exception of the first pipe symbol (>) is simply the Unix operating system command line which invokes the spooler. The options used most often are: 

-s                  Suppress all messages from the spooler 
-d                  Select printer destination if other than system default 
2>/dev/null         Send error messages to the null device instead of to the terminal 

Some other options you might want to specify when using the spooler are the $COPIES, or $FORM variables. For example: 

        alias LP “> lp -s -dhplaser -c$COPIES 2>/dev/null” “Spooler” CR,COPIES=1 

Some Unix operating system spoolers will allow you to specify a specific number of copies to print by passing to the spooler some flag (-c) plus a number. BBx can accommodate this and improve your programming code by using a variable to represent this number of copies. The default number of copies is 1, as found at the end of the alias line. When opening the printer from within your program, you can vary this number of copies by using the “MODE=” option on your open. If you want to print 5 copies of this particular report, open the printer like this: 

open (7,mode=”COPIES=5″)”LP” 

BBx replaces the $COPIES variable on the piped command line with the number 5. Your spooler takes care of the rest. Additionally, BBx will look in the user environment for a COPIES= value, for the situation where one particular user always wants multiple copies of everything. 



Last Modified: 11/17/1998 Product: PRO/5 Operating System: Unix

BASIS structures five components of their technology into the BBx Generations.

Table of Contents
Scroll to Top