Next Up Previous Contents
Next: 3.3 Processing many bitmaps
Up: 3 Usage notes
Previous: 3.1 Good choices of fonts and scaling
[ID index][Keyword index]

3.2 Using dvi2bitmap in a pipe

dvi2bitmap is perfectly happy reading DVI files from a pipe, so that


cat myfile.dvi | dvi2bitmap --pipe -
will work perfectly well. Since the program knows that the standard input -- indicated by the - argument to dvi2bitmap -- is not seekable, the option --pipe is actually redundant. This is not by itself particularly useful, since TeX is not written to send its DVI output into a pipe.

If, however, you make a `named pipe' beforehand, using the Unix mkfifo command (a FIFO, or first-in-first-out, is the other name for such an object), then TeX can be persuaded to send its output there.


% mkfifo myfile.dvi
% ls -l myfile.dvi
prw-r--r--  1 norman  admin  0 Aug 12 00:18 myfile.dvi
% latex myfile >myfile.stdout &
% dvi2bitmap --pipe mkfile.dvi
Here, we create the FIFO using the mkfifo command; looking at it, we see that the first character on the ls line is a p, indicating the type of object it is. We start (La)TeX going in the background (achieved by the &), putting its chatty output into a file, and it merrily writes into the `file' myfile.dvi. Immediately afterwards (we've shown this on two lines, but the two commands could be run together with only the & separating them) we start dvi2bitmap, telling it to read from the named pipe. The pipe effectively synchronises the two processes, so that if there is nothing to read, dvi2bitmap is briefly suspended, and if the pipe is full, LaTeX is suspended. After this performance, the DVI file, myfile.dvi ends up zero size again, and the process can be repeated.

You can go further than this, and use a FIFO for LaTeX's input, too:


% mkfifo myfile.tex myfile.dvi
% cat foo.tex >myfile.tex & \
    latex '\input myfile.tex' >myfile.stderr & \
    dvi2bitmap --pipe myfile.dvi
(the trailing backslashes indicate that this second set of commands is all on one line). The rather odd form of LaTeX invocation (note the quotes) stops TeX from peeking at the file, looking for the magic %& line which can tell it which format to use; since the input is a pipe, it's unseekable, so we must use this form, or else LaTeX fails.


Next Up Previous Contents
Next: 3.3 Processing many bitmaps
Up: 3 Usage notes
Previous: 3.1 Good choices of fonts and scaling
[ID index][Keyword index]
Dvi2bitmap -- convert DVI files to bitmap images
Starlink System Note 71
Norman Gray
14 June 1999. Release 0.12. Last updated 20 December 2003