[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: lua system interaction on win
- From: "Martin Spernau" <martin@...>
- Date: Tue, 20 Aug 2002 21:52:12 +0200
I have a problem that seems to be rather simple for *IX systems that have
pipes, but I need to do this in windows.
- start an external process and read it's output.
- bonus: write to the stdin of the external process
on systems that support pipes the following example code works fine:
-- invoke the 'ls' command
-- NOTE 'ls' is just an example
-- goal is to use any programm that outputs data to stdout
h = readfrom("| ls -l") -- this will fail on win
o = read("*a") -- read from it's stdout
-- do something with o
(obviously the 'ls' command needs to be replaced with something like 'dir'
Now lua compiled for Windows doesn't support the '| command' functionality
for readfrom(), as it doesn't have 'pipes'
Of course one could use a construct like
execute("dir > temp.txt")
o = read("*a")
But is there a nicer way to do that in Windows?
(I've done this kind of thing from VB, using the win32 API...)
Or would I need to handle this in some platform specific lib?
I'd be happy for any ideas/pointers