MiKTeX 2.5: Piped input and output

by CSchenk22. June 2006 03:31

This is a new feature in Beta 11:

TeX's input/output primitives can now be used for unidirectional interprocess communication by prepending a pipe symbol to the file name.

If this feature is enabled, then \input "|command" starts the command interpreter (usually cmd.exe) to carry out the command. The output of the command becomes the input of TeX. For example:

\input "|dir/b"

typesets the file names of the current directory.

Likewise, it is possible to let TeX write something into the input stream of a command. For example:

\immediate\openout1 = "|unix2dos|sort > sorted"
\immediate\write 1 {b}
\immediate\write 1 {a}
\immediate\write 1 {c}
\immediate\closeout1
\input sorted

typesets a b c.

Piped input and output is disabled by default to avoid security problems. You enable the feature by specifying -enable-pipes on the TeX command-line.
 

Comments (5) -

CSchenk
CSchenk
6/22/2006 1:01:33 PM #

The COMSPEC variable is used. That's hardcoded in the C runtime library (I'm
using _popen/_pclose).
          

Lionel Fourquaux
Lionel Fourquaux
6/22/2006 1:23:10 PM #

How is the command interpreter determined? Do you use the COMSPEC or SHELL environment variables, or some custom mechanism? Is there a way to override this choice from within TeX, or from the configuration tools? (Example scenario: I want to leave COMSPEC to its default value for compatibility, but I would like TeX to use directly the MS PowerShell).

          

Maurice Lombardi
Maurice Lombardi
6/24/2006 1:14:57 PM #

In the first example, I had found more logical to type

\input "dir/b |"

i.e. | at the end: the output of dir/b is input for TeX
keeping the convention
output of process # 1 | input of process #2
          

CSchenk
CSchenk
6/24/2006 1:34:12 PM #

I agree. See www.tug.org/.../010720.html

Yuri
Yuri
8/13/2006 2:23:07 AM #

In the first example, how I can output the backslash symbol in directories and files names like C:\directory\file.ext?
I have an error because backslash is escape character.
Other problem is with the symbol "_" in files and directories names.
I solve this errors only by changing the catcodes of this symbols.
.
          

Comments are closed