(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version



This article is from a FAQ concerning SCO operating systems. While some of the information may be applicable to any OS, or any Unix or Linux OS, it may be specific to SCO Xenix, Open Desktop or Openserver.

There is lots of Linux, Mac OS X and general Unix info elsewhere on this site: Search this site is the best way to find anything.

Printing FAQ

How can I get the file from the print spooler before it prints?





Sometimes you want the results of a print job so that you can e-mail it to someone else, import it into a Word Processing document or whatever. This is simple to do.

Put the printer OFF-LINE as described above. Alternately, if you have not yet printed, "disable" the printer (see above). Now


 cd /usr/spool/lp/temp
 l [0-9]*-* | more
 

You will see something like this:

 rw-rw---- 1 lp  lp   71 Dec 1 09:15 178-0
 rw-rw---- 1 lp  lp   83        Dec 1 09:16 179-0
 rw-rw---- 1 lp  lp 7809 Dec 1 09:15 179-1
 

Your dates and sizes will be different, as will the names of the files.

These files are information about what is to be printed and how. For example, if you looked at that 178-0 file on my machine, you'd find it contained:

 C 1
 D myprinter
 F /etc/passwd
 P 20
 t simple
 U root
 s   0000
 l C_C.C
 m C_C.C
 

while the 179-0 had this in it:

 C 1
 D myprinter
 F /usr/spool/lp/temp/179-1
 P 20
 t simple
 U root
 s   0000
 l C_C.C
 m C_C.C
 

Notice the difference between the two. You might have already guessed that the "C" line is the number of copies, the "D" is the printer it's going to print on, and the "U" is the user who printed it. The "F" is the file that will be printed, and if it was generated as the result of program output (as opposed to "lp /etc/termcap"), it will refer to another file in this directory.

If you have more than one print job, you might not know which file is the one you want. If the size of the -1 files combined with the destination and user isn't enough to help you, then examine each -1 file in turn. Once you have what you want, copy the file wherever you want it. If you don't want it to print after that, cancel it. For example, I might say:

 cp /usr/spool/lp/temp/179-1 /tmp/printfile
 cancel myprinter-179
 

If you want this to happen automatically, you need to modify the interface script to copy the file somewhere. That can be as simple as adding a line like:

cat $6 > /tmp/savestuff/$1
# Thanks to Michel Donais for this suggestion
 

though you may want to do more of course. Sometimes it's simple to examine the print stream and make up a file name that relates to the contents. Don't do that directly in the script; do something like

cat $6 | someotherprog
 

and let "someotherprog" figure out what to do. <<p>If more than one file is printed, it may be necessary to do this later in the script, after the non-file arguments have been shifted off. You'd "cat $*" instead. Read the rest of this document if you don't understand that yet.





Lpd style printing doesn't put files here: you'll find those in /var/spool/lpd/printername or wherever else /etc/printcap points at.




Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar

cartoon


/SCOFAQ/FAQ_scotec7grabprint.html copyright 1997-2003 (various) All Rights Reserved

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.


book graphic unix and linux troubleshooting guide

My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!



 I sell and support
 Kerio Mail server






More:
       - FAQ
       - Printing


Unix/Linux Consultants

Skills Tests

Guest Post Here











My Favorites

Change Congress