[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How would I go about getting the duration of a WindowsMediaFileusing Lua?
- From: "Aaron Brown" <aaron-lua@...>
- Date: Fri, 4 Nov 2005 10:32:53 -0500
Mike Vidal wrote:
> How do I capture the output of a command line program with
> os.execute ? Is the only way to redirect the commands
> output to a file then read that?
Basically, yes.
If the proper switch was flipped at compilation (look for
"POPEN" in the config file), and if it's supported by your
platform, Lua 5.0.2 has the undocumented function io.popen,
which returns a read-only file handle from which you can
read the output of a command:
local Hnd, ErrStr = io.popen("ls -la")
if Hnd then
for Line in Hnd:lines() do
print(Line)
end -- for Line
Hnd:close()
else
print(ErrStr)
end -- if
--
Aaron