473,322 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Starting New Process

D
Hello, I need to write a server program that performs the following
tasks:

1) Listens on TCP port 5555 for a connection
2) When client connects, launches application (for example, vi), then
closes connection with client
3) Goes back to listening on TCP port 5555 for an incoming connection

The main thing I need to make sure of is that when the server program
closes, that the applications that were launched remain running (i.e. I
would need to launch them independently of the server program). Any
help as to how to do this would be greatly appreciated!

Jun 1 '06 #1
4 1625
D
Thanks, Jean-Paul - is there any way to do it without using Twisted,
since I am not very familiar with it? (i.e. just using the os library)
Thanks.

Jean-Paul Calderone wrote:
On 1 Jun 2006 07:34:23 -0700, D <du********@hotmail.com> wrote:
Hello, I need to write a server program that performs the following
tasks:

1) Listens on TCP port 5555 for a connection
2) When client connects, launches application (for example, vi), then
closes connection with client
3) Goes back to listening on TCP port 5555 for an incoming connection


Untested:

from twisted.internet import protocol, reactor

class ViRunner(protocol.Protocol):
def connectionMade(self):
reactor.spawnProcess(
None,
'/usr/bin/setsid',
['setsid', '/usr/bin/vi'])
self.transport.loseConnection()

f = protocol.ServerFactory()
f.protocol = ViRunner
reactor.listenTCP(5555, f)
reactor.run()

Jean-Paul


Jun 1 '06 #2
D wrote:
Thanks, Jean-Paul - is there any way to do it without using Twisted,
since I am not very familiar with it? (i.e. just using the os library)
Thanks.

Jean-Paul Calderone wrote:
On 1 Jun 2006 07:34:23 -0700, D <du********@hotmail.com> wrote:
>Hello, I need to write a server program that performs the following
>tasks:
>
>1) Listens on TCP port 5555 for a connection
>2) When client connects, launches application (for example, vi), then
>closes connection with client
>3) Goes back to listening on TCP port 5555 for an incoming connection


Untested:

from twisted.internet import protocol, reactor

class ViRunner(protocol.Protocol):
def connectionMade(self):
reactor.spawnProcess(
None,
'/usr/bin/setsid',
['setsid', '/usr/bin/vi'])
self.transport.loseConnection()

f = protocol.ServerFactory()
f.protocol = ViRunner
reactor.listenTCP(5555, f)
reactor.run()

Jean-Paul


Use import socket ifyou don't want to use twisted (which is incredibly
good). Google for "+socket +python +server" and you will find what you are
looking for.

See, for example,
http://floppsie.comp.glam.ac.uk/Glam...ireless/5.html

Carl
Jun 1 '06 #3
D
Sorry, I should've specified - I'm familiar with sockets, but I was
referring to spawning a 'vi' process independent of my Python app..
Carl wrote:
D wrote:
Thanks, Jean-Paul - is there any way to do it without using Twisted,
since I am not very familiar with it? (i.e. just using the os library)
Thanks.

Jean-Paul Calderone wrote:
On 1 Jun 2006 07:34:23 -0700, D <du********@hotmail.com> wrote:
>Hello, I need to write a server program that performs the following
>tasks:
>
>1) Listens on TCP port 5555 for a connection
>2) When client connects, launches application (for example, vi), then
>closes connection with client
>3) Goes back to listening on TCP port 5555 for an incoming connection

Untested:

from twisted.internet import protocol, reactor

class ViRunner(protocol.Protocol):
def connectionMade(self):
reactor.spawnProcess(
None,
'/usr/bin/setsid',
['setsid', '/usr/bin/vi'])
self.transport.loseConnection()

f = protocol.ServerFactory()
f.protocol = ViRunner
reactor.listenTCP(5555, f)
reactor.run()

Jean-Paul


Use import socket ifyou don't want to use twisted (which is incredibly
good). Google for "+socket +python +server" and you will find what you are
looking for.

See, for example,
http://floppsie.comp.glam.ac.uk/Glam...ireless/5.html

Carl


Jun 1 '06 #4
D
Sorry to bring it back up, but is there a way to spawn the process
without Twisted?

Jun 5 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: serge calderara | last post by:
Dear all, I have an application which is suppose to start another executable process. As soon as that process is running, I need to retrive its handle. The problem of the particular process I am...
3
by: Timothy Shih | last post by:
Hi, I am trying to start a process from inside a .NET service. The process is a simple GUI app, the service will start up the GUI and then stop itself. The service starts the app, but no GUI...
0
by: Shruti A via .NET 247 | last post by:
hello group I have recently started working on .Net platform. I am facing one problem in killing and starting process from my aspx page. I am able to kill and start the same process from vb.net...
3
by: Christopher | last post by:
One of our ASP.NET Pages is starting a new Process using the Process object. When the process starts, it is started under the ASPNET User. We tried editing the web.config file and the...
0
by: Mark Henry | last post by:
I wrote a Desktop class for manipulating desktops and window stations. The class is being used by a service for starting applications on the interactive desktop (the service cannot run as Local...
5
by: Benzi Eilon | last post by:
I have written a C# application which should run as a Windows Service. I must avoid having multiple instances of the application on one machine so I inserted the following code at the beginning of...
8
by: cypher543 | last post by:
This has been driving me insane for the last hour or so. I have search everywhere, and nothing works. I am trying to use the subprocess module to run a program and get its output line by line. But,...
4
by: JamesB | last post by:
Hi, I need to trap a particular process starting or ending. I have done this using process.start from within my own app, but powers that be really want it to be seperate (i.e. my app should...
0
by: Dominic | last post by:
Every thing work fine when I am not starting process as another user. When I am starting process as another user, the authentication is working (I can see it in my workstation security log), but...
1
by: ropo | last post by:
I have a .NET 2.0 app that at one point starts an old MFC App through System.Diagnostics.Process.Start from a model form/ I then wait for it to finish by calling StartedProcess.WaitForExit(); ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.