i'm trying to capture output from an external command in a XeLaTeX document. as per https://tex.stackexchange.com/a/20566/28067 and https://stackoverflow.com/a/8929976/256361, i'm specifically doing




\immediate\input{|"node -v"}



i'm running TeX with xelatex --enable-write18 --enable-pipes write18.tex to enable features normally blocked (because security).

however, this does not appear to work. i've tried the \input command with and without the braces, and with and without \immediate, but as long as that line is in the source, XeLaTeX concludes output with


rather than

(./write18.aux) )
Output written on write18.pdf (1 page).
Transcript written on write18.log.

(ie there is an additional newline, and output just stops dead without the remaining lines). observe that on my system, the output of node -v is the completely un-dangerous string v0.11.7. i understand that in order to capture more arbitrary output i'd have to fiddle with catcodes, but that's food for another question.

so what am i doing wrong here?

Update @egreg you might be right! i tried

\immediate\write18{node -v > /tmp/temp.dat}

and that did work. funny though it would appear you told readers in a comment to https://tex.stackexchange.com/a/20566/28067 that "in TeX Live 2013 the syntax \input|"command" is supported also by XeTeX"–were you in error here?

btw the fact that (in TeXLive) using non-supported command line options do not seem to trigger error messages does not exactly help make testing easier. also funny that http://docs.miktex.org/manual/xetex.html has all the long options prefixed with two dashes where xelatex --help gives them with a single dash (and fails to even mention that many more options are available).

  • Unfortunately, the pipe doesn't seem to work on XeTeX.
    – egreg
    Jan 8 '14 at 15:20
  • You are using xelatex. Latex redefines \input and so - as mentioned in the first question you are linking too - you must use \makeatletter\@@input|"...". Jan 8 '14 at 15:54
  • @UlrikeFischer i'm trying to get that working but seemingly can't. if you're confident, mind to share a MWE with the rest of us?
    – flow
    Jan 8 '14 at 16:24

I used this





which gave me some errors as the output of dir also contains a path with a backslash but beside this did what was expected: I got 12 pages of more or less sensible output (my test folder is large ;-)). I called xelatex with --enable-pipes --shell-excape. It worked with miktex and TL 2013 on windows. (--enable-pipes is not known in texlive but did no harm).

  • see, that's the difference—i'm working on OSX, not on windows. doing the exact code you gave (with ls substituting dir) i get the behavior described in my question. i'm not surprised that miktex behaves differently, but that TeXLive is si different on different OSes is new to me.
    – flow
    Jan 8 '14 at 17:27
  • Gotta love the test folder. :) Currently mine has 384 files (per ls -1 | wc -l) :) Jan 9 '14 at 0:08
  • I tried it with the command \@@input|"ls -l" on MacOS X 10.14.5 (command line: xelatex --shell-escape test.tex and it worked (xelatex version XeTeX, Version 3.14159265-2.6-0.999991 (TeX Live 2019)). There doesn't seem to be a --enable-pipes command line option.
    – yannis
    Aug 29 '19 at 2:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.