![](https://secure.gravatar.com/avatar/d39338246f50cca667c8256c313d7cfd.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
On 4/14/2013 12:06 PM, Marco Patzer wrote:
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
context(os.resultof("ls"))
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
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Marco Patzer