|Printing Command To Be Used
Printing : Commands covered in this section: lpr, lpq, lprm, enscript
At the time that UNIX was being developed, line printers were all the rage. This is reflected in the simple printing system used in UNIX. This system consists of a print server (called lpd on many systems), which sends jobs placed in the print queue to the printer, and several client programs that allow you to place jobs in the print queue (lpr), check the status of the print queue (lpq), and remove jobs from the print queue (lprm).
Use the lpr command to send a simple text file to the printer.
If no printer is specified, lpr will send the print job to the default printer. To specify an alternate printer, use the "-P" option.
Use lpr -P to print to a specific printer.
Since UNIX is a multi-user system, there's a chance that several users will be sending jobs to the printer simultaneously. To check on the status of your print job, you can use lpq.
Check on the status of the "myprinter" print queue using lpq.
The display returned by lpq is a table, showing the rank of each pending job, the user who owns the job, the job id, the name of each file, and the size. If you omit the "-P" option, lpq will show the status of the default print queue.
To remove a print job from the queue, use the lprm command. You can remove a particular job by specifying its job id.
Remove a pending job from the "myprinter" print queue using lprm.
In this case, the user sneezy is removing job number 6 (myfile2) from the queue.
As with lpr and lpq, omitting the "-P" flag causes lprm to perform the requested operation on the default print queue.
The lpr command usually just copies the specified file into the print queue unmodified, whether it's a simple text file or a PostScript file (PostScript is a page description language developed by Adobe). In some cases, you may want to modify a text file (adding margins, a header, etc.). One command that allows you to do this is enscript (this program was created by Adobe; there are two free clones: genscript and nenscript). These programs are not part of most standard UNIX distributions, but they are often installed by the system administrator.
enscript has many options, but a few of the useful ones include "-G" (add a "gaudy" header, including current date/time, file name, and page number), "-r" (rotate the page orientation to landscape), and "-2" (print two columns instead of one). In order to make these changes to a text file, enscript converts it to PostScript.
Print a text file using enscript with the options specified above.
% enscript -2Gr -Pmyprinter /etc/hosts
Have a Unix Problem
Return to : - Unix System Administration Hints and Tips
(c) www.gotothings.com All material on this site is