How Do I Print from Unix and Linux?
NOTE: Users wishing to print from the CETS printers located in Levine 164 or Towne M70 must adhere to the following policies, also available in the Eniac Policy:
Command Line Printing
If you're logged into a unix server or linux terminal, you may print text files or postscript files using the "lpr" command. This command prints to the default printer. Currently the default printer on CETS computers is set to the Levine 164 queue. To print a text file called "hrsprn", enter
% lpr hrsprnIf you would like to print to a different printer in the system, follow the lpr command with "-P" followed immediately by the name of the printer. For example, to print the "hrsprn" file to the Towne M70 queue, enter
% lpr -PPay-to-print_M70 hrsprnand, similarly, you may print to Levine 164 by entering
% lpr -PPay-to-print_169_Color hrsprnThe "lpr" command also accepts files in the Postscript format. Do not attempt to print non-text or non-Postscript files, though, because this can cause the printer to malfunction. See below for some printing solutions for other file types.
If you would like to print an image file from Unix or Linux, you will need to open the file in an imaging program. If the file is of a common internet format, such as GIF or JPEG, it is probably easiest to use the your browser to open the image and print it. Otherwise, the "xv" program should be used. XV is a program written by Penn's own John Bradley, and is widely used to manipulate images in Unix and Linux. To print the image, simply open it in XV, and hit the print button. You'll notice that the print dialogue box allows you to change the print command.
Save Paper by Compressing Output
To help conserve paper, comply with the Eniac Policy and save the rainforests, we recommend that you try one of the available print compression programs available on Eniac.
The "mpage" command is the fastest and most simple way to save paper on Eniac. To print the file "hrsprn" so that four pages are printed on a single sheet of paper, type
% mpage hrsprnThis will cause the document to be printed on the default printer in the CETS office. If this is too small to read, and you want to sent it to the printer in Towne M70, use the command
% mpage -2 -PPay-to-print_M70 hrsprnIn this command, the "2" represents the number of pages of text to print per sheet of paper, and the "P129" represents the name of the printer using the same syntax as the "lpr" command. For more information, type "man mpage" at the Eniac command prompt.
The "enscript" command works basically the same way as mpage, but is much more customizable. For information on using enscript, type "man enscript" at the command prompt. NOTE: Enscript only works on text files, whereas Mpage works on both text and postscript files.
Compressing Internet Printouts
As described above, web browsers allows you to change the command it uses to print files. This functionality makes it possible to compress internet printouts. You can do this by clicking on "File", selecting "Print...", and replacing the lpr command with the print protocol you would like to use. For example, if you would like to use mpage to print four pages of text per sheet of paper, click on the box and replace
Most text data can be printed by using a pipe (|) in Unix or Linux. This is performed by placing a pipe at the end of a command and following it with the "lpr" command. For example, to print a listing of the current directory to the printer in Towne M70, enter the following command:
% ls | lpr -PPay-to-print_M70If you have a very large directory listing, and you would like to use the comprehensive listing (-l) option of the directory, you can pipe to the mpage program to compress it to six pages per sheet of paper by entering this:
% ls -l | mpage -6
Change the Default Printer
If there is a printer that you plan on using more than the default one in the CETS office in Levine 164, it may be in your best interest to change your default printer. To do this, add the following lines to the end of your ".bashrc" file:
PRINTER=printernameChange "printername" to the name of the printer you want to be your default. For example, to set your default printer to the Towne M70 queue, the line in your ".bashrc" file should read
PRINTER=M70After you save this to the file, changes will not take effect until the next time you log in. So logoff and log back in to use the new printer.