APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

SCO Unix/System V Printing FAQ

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.

How can I get the file from the SCO Unix/System V 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.

Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> (SCO Unix) How can I get the file from the print spooler before it prints?

Printer Friendly Version

Have you tried Searching this site?

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.

Contact us

Printer Friendly Version

The whole thing that makes a mathematician’s life worthwhile is that he gets the grudging admiration of three or four colleagues. (Donald Knuth)



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode

SCO Unix Sales, Support, & Service

Phone:  707-SCO-UNIX (707-726-8649Toll Free: 833-SCO-UNIX (833-726-8649)