On 6/7/07, Alexey Maksimov <<a href="mailto:alexey.maksimov@gmail.com">alexey.maksimov@gmail.com</a>> wrote:<br>> Hi,<br>> <br>> Please help me with the following:<br>> <br>> I want to write a simple app that should remotely control
<br>> long running shell process. I have a C++ program that does some network<br>> capturing I need. I want to create a simple web interface that can<br>> start and stop this program via shell on linux.<br>> <br>
> I already wrote a web part of this but failed to spawn my process.<br>> I think my problem is that I want to use myserver.tac and don't want<br>> directly call reactor.run() as shown in documentation.<br>> How can I spawn my long-running process without using
reactor.run()?<br>> <br>> Thanks in advance,<br>> Alexey.<br>> <br>> _______________________________________________<br>> Twisted-Python mailing list<br>> <a href="mailto:Twisted-Python@twistedmatrix.com">
Twisted-Python@twistedmatrix.com</a><br>> <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br><br>I'm not sure I understand your problem, but here's what I think you should do:
<br><br>Write a twisted application (maybe this is your myserver.tac?) which is a simple web server. An easy way to write a twisted web app is with nevow. Since this is a twisted application, assuming your myserver.tac file defines an object named "application", just run it with:
<br><br> twistd -noy myserver.tac<br><br>The twistd program will automatically call reactor.run() for you, you normally do not need to call it explicitly.<br><br>Now, to launch another process from twisted there are several API's you can use.
<a href="http://twistedmatrix.com/projects/core/documentation/howto/process.html">This page</a> in the docs explains the most general way, where you have complete control over the inputs and outputs to the spawned program. There's also a simplified API for launching programs, but it just grabs your process's output:
twisted.internet.utils.getProcessOutput().<br><br>Cheers,<br>Christian<br><br>