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 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.
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.
Got something to add? Send me email.