Pipo - make any program a filter


Some programs (often those from a non-Unix background) don't read input from stdin, nor write to stdout. Instead, they make you specify an 'input file' and an 'output file' on the command line. At least most Unix programs that do this let you use the special filename '-' to mean stdin or stdout, but there are some programs that don't recognize this convention.

Sometimes this is for technical reasons, because the input needs to be seekable. Sometimes it is because the author didn't think it would be useful and is probably a Pascal sympathizer :-). But in any case, it is annoying not to be able to use such programs in pipelines.

Pipo fixes this problem. It wraps such programs and lets you give filenames of '-' as you would with any other. However pipo doesn't know whether '-' should mean stdin or stdout, so you must tell it with the -i, -o, or -b switches. Pipo also provides -I and -O for programs which can use stdin and stdout but require them to be seekable.

For example, to convert the program 'stupid', which takes an input filename and an output filename, to be a filter:
pipo -io stupid - -

To pipe a C program through the compiler (if for any reason you needed to do such a thing):
pipo -io gcc -.c -o -
In this case, the temporary input filename given to gcc will end in '.c'.

And to pipe some text through emacs, giving the user the chance to edit it:

pipo -b emacs -

An example of the -I switch, to buffer stdin into a file so that dvips's 'filter' mode (which expects a seekable stdin) can use it:

pipo -I dvips -f

See the manual page for more.


Although pipo is general enough for most uses, it won't handle TeX and LaTeX properly. For this there is a separate program pipo_latex which is a wrapper for LaTeX. It accepts LaTeX source on standard input and writes a DVI file to standard output - or you can install it as pipo_tex if you don't use LaTeX. It tries to do something sensible with TeX's error messages - see the documentation at the start of the script. For example:
cat filename.tex | pipo_latex | pipo -i xdvi -


This is a special-purpose wrapper for the latex2html program. It reads LaTeX source from stdin and tries to convert it to HTML written to stdout.

Pipo versus /dev/stdin and /dev/stdout

On most Unices, you can often get the same effect as pipo by using /dev/stdin and /dev/stdout (thanks to Daniel Biddle for pointing this out). However although this works for programs which read and write sequentially, and gets you the normal pipeline laziness in such situations, it won't work for those that want to do random-access file operations on their input or output.

Try running your program with /dev/stdin or /dev/stdout; if it fails in some strange manner, try again using pipo, which should work with just about anything. Also pipo works on Windows, where /dev/std* don't exist.


The latest version is 1.3, which changes name to 'pipo' from 'pip'.


As for Perl modules. 'perl Makefile.PL' then 'make test; make install'.


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

A copy of the GNU General Public License is included as the file COPYING.


Please contact me with any suggestions or bug reports:
Ed Avis <ed@membled.com>