Because Unix is a multiuser environment, it would only make sense that more than one person would be printing to a printer at any single time. When you print in Unix, your print job is sent with a print job number. This number is assigned to the job by Unix to track and complete the job. Canceling a print job after you start one is canceled based on that job number. The job is removed from the print queue and then you no longer have a print job pending.
Now that you understand the fundamentals of printing in Unix, let's take a look at how to actually get it done.
With the lpd (line printer daemon and its protocol) system available on your machine, you can use the lpr suite of commands to send print jobs to your printer. The lpr (line printer) command is the primary method for sending data to the printer and is available on most, if not all, Unix systems unless disabled or removed. lpr essentially dumps all data directly to the printer that you specify. To use lpr, follow these steps:
1. | Determine the name of the printer you want to use. In some cases, your Unix system administrator will give you the name. |
2. | Choose the file you want to print such as a text file. If you do not have one to print, make one with emacs or vi. |
3. | |
4. | If there is only one printer configured on your computer, chances are you can simply type lpr <filename> <filename>.... |
Let's look at an example of how to print out a print job. As an example, type the following:
>lpr –Ppr1 anyfile.txt
The result of this command is that the file anyfile.txt is sent to the printer named pr1. If the printer is not busy, then the print job will be printed immediately. If the need arises, you may need to print multiple copies of a document. You can do this by entering the same command once for each copy you need, or by simply specifying the number of copies as an option to the lpr command.
No Print Job for You! You may not be able to print because you are not configured to do so. Running the lpr command may give you an error such as “no default destination available” or some other error (it will be different based on your Unix version) that simply states that you do not have a destination device for your hardware printer to send the job to. Because of this, Unix just tells you “sorry—no print job for you!” |
Specify the number of copies as an option to the lpr command by doing the following: type lpr with -#<number of copies> to print that many copies of each file in the job. That's it!
Also, there are a few file formats and special print cases that might require special attention from the print command. Filters are applied to a file to convert the information to a special format. The format can be any that the printer can handle. Here are a few examples of common filters:
.ps— This extension stands for postscript files. Postscript files will be handled automatically by the lpr command. You can print them as you print a plain text file.
.dvi— This extension stands for text files. Files from text contain special page layout instructions. You can use the -d option with lpr in order to print these files correctly.
.tr— This extension stands for troff files. This is the standard file format for man pages. You can use the -t option to print out a man page.
Now you know how to print with Unix, and some of the commands you can use to send jobs to a printer. We now need to know how to check the status of a print job, so that if a problem occurs it can be dealt with quickly.
My Cups Runneth Over… CUPS, or the Common Unix Printing System, also uses filters. CUPS is the newer model that Unix and Linux are based on, which is more standardized. CUPS is a modular Unix printing system that allows your system to act as a print server. CUPS was designed to be easier to network than standard Unix printing solutions. CUPS consists of a Unix print spooler, a scheduler, as well as a filtering system. When using CUPS, you will see a big advantage in that it can process a variety of formatted data to the print server through the use of its filters. It converts the print job data into the format the printer will understand. CUPS does this using MIME (Multipart Internet Mail Extensions) types. MIME is an Internet Standard for the format of email, but is commonly used in other systems to determine the type of file that is being processed. |
|
18.219.12.23