lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi all,

what I'm missing most in the standard IO library is the possibility to choose arbitrary file descriptors. The problem is, I have a Lua program A from which I start an xterm which executes program B:

	os.execute("xterm -e B")

At exit, B prints a result, which I want to read and process in A. A pipe doesn't help here, because

	io.popen("xterm -e B")

reads the output of xterm (which is always empty), while the output of B goes into nirwana.

In bash (I'm on Linux, as you may have guessed) I would do this:

	result=$(xterm -e "B >&3" 3>&1)

but it seems that an equivalent trick is not possible in Lua. I can of course use a temporary file, but I wonder if there is a more elegant way in Lua?

Bernd

--
Bernd Eggink
http://sudrala.de