How can I save shell output to a variable in LaTeX?

Posted by Frank on Stack Overflow See other posts from Stack Overflow or by Frank
Published on 2010-04-19T21:32:09Z Indexed on 2010/04/19 22:33 UTC
Read the original article Hit count: 163

Filed under:
|
|

I need to be able to execute a shell command through LaTeX [*] and have the resulting output available for use later on in the form of a LaTeX 'variable' (e.g., via a subsequent \newcommand command). If necessary a temporary file could be used to hold the output, although I would like to avoid this. I have been able to use

\immediate\write18

to invoke a bash command before, but this was only used to write to a temporary file.

[*] I realise that the -shell-escape flag must be set for this to be allowed

© Stack Overflow or respective owner

Related posts about tex

Related posts about latex