[NTG-context] Read output of external command

Marco Patzer homerow at lavabit.com
Sun Apr 14 12:06:13 CEST 2013


Hi,

I need to read the standard output of an external command. This is
what I came up with:

\starttext
  \startluacode
    f = io.popen "ls"
    context(f:read "*a")
  \stopluacode
\stoptext

It works with luajittex, plain lua5.1 and lua5.2, but it fails with
a current luatex:

! LuaTeX error [string "\directlua "]:3: attempt to index global 'f' (a nil value)
stack traceback:
	[string "\directlua "]:3: in main chunk.

Why does this fail in luatex but works in lua5.2 ? What is the
correct way to obtain the output of a command?


Marco
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20130414/b3092e5b/attachment.pgp>


More information about the ntg-context mailing list