[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua fork concurrent processes
- From: Michal Kolodziejczyk <miko@...>
- Date: Mon, 05 Nov 2012 11:16:47 +0100
On 05.11.2012 09:46, ms2008vip wrote:
>
> Howdy:
>
> I want to execute background processes concurrently from a lua script
> like :
>
> a = io.popen("deploy.exp" .. ip1):read("*a")
> b = io.popen("deploy.exp" .. ip2):read("*a")
> **
> where a,b are continually running processes. When i do this as above, b will only run when a is finished. And the deploy.exp script is an expect script which
> used to ssh few servers, and execute some commands. Then I need to fetch some text from a and b. Any idea on this? I tryed with the ExtensionProposal API.
Do they really work "continually"? If so, you should not read all the
data, but just what is output. For example:
a=io.popen("deploy.exp" .. ip1)
b=io.popen("deploy.exp" .. ip2)
while a and b do
if a then
linea=a:read('*l)
if not linea then
a:close()
a=nil
end
print('Got from a:', linea)
end
if b then
lineb=b:read('*l)
if not lineb then
b:close()
b=nil
end
print('Got from b:', lineb)
end
end
Note that this still blocks on reading a line. I would use luasocket and
select() to resolve this, but the scripts then should use (TCP/UDP/Unix)
sockets instead of stdout.
Regards,
miko