[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua + cgilua + lightttpd
- From: Petite Abeille <petite.abeille@...>
- Date: Mon, 5 Aug 2013 20:28:01 +0200
On Aug 5, 2013, at 7:50 PM, Henrique Gogó <henriquegogo@gmail.com> wrote:
> fname = os.tmpname ()
> os.execute ("/bin/bash -c set > " .. fname)
> f = io.open (fname, "r")
> s = f:read ("*a")
> print (s)
> f:close () -- close it
> os.remove (fname)
A bit unrelated to the topic at hand, but for the record…
Say one would like to invoke an external command to, say, identify all environment variables of a process… io.popen is your friend:
http://www.lua.org/manual/5.2/manual.html#pdf-io.popen
Usage example:
lua << \EOF
local aHandle = assert( io.popen( 'env' , 'r' ) )
for aLine in aHandle:lines() do
print( aLine )
print( ( 'key = %q value = %q' ):format( aLine:match( '^(.-)=(.-)$' ) ) )
end
EOF