Client/Server Question

bruce bedouglas at earthlink.net
Fri Jul 28 18:20:56 EDT 2006



-----Original Message-----
From: python-list-bounces+bedouglas=earthlink.net at python.org
[mailto:python-list-bounces+bedouglas=earthlink.net at python.org]On Behalf
Of faulkner
i'm not familiar with python's os/system/exec functions, but i'm willing to
bet that you're running into an issue with how the "system" function works.

look for a function that allows you to spawn an external app, but that
dosen't wait (or require) the child app to return.

i would also suggest that you work with a client/server setup on the same
machine as a test. furthermore, i would suggest that you have your server do
something like print put to a file/cmdline so you can actually verify that
it's working as it should. once that's working well, then hook in the
system/exec/spawn functionality...

good luck




Sent: Friday, July 28, 2006 3:06 PM
To: python-list at python.org
Subject: Re: Client/Server Question


you might want to look at sshd. if you're on a windows box, you may
need cygwin. if you're on linux, you either already have it, or it's in
your package manager.

diffuser78 at gmail.com wrote:
> My server.py looks like this
>
> ---------------------------------------------CODE-------------------------
---------
> #!/usr/bin/env python
> import socket
> import sys
> import os
>
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> host = ''
> port = 2000
>
> s.bind((host,port))
> s.listen(1)
> conn, addr = s.accept()
> print 'client is at', addr
>
> while True:
> 	data = conn.recv(1000000)
> 	if (data == 'MaxSim'):
> 		print 'MaxiSim'
> 		os.system('notepad')
> 	elif (data == 'Driving Sim'):
> 		print 'Driving Sim'
> 		os.system('explorer')
> 	elif (data == 'SHUTDOWN'):
> 		print 'Shutting down...'
> 		os.system('shutdown -s')
> 		conn.close()
> 		break
> -------------------------------------------CODE
> END-------------------------------------
>
> I am running this above program on a windows machine. My client is a
> Linux box. What I want to achieve is that server.py should follows
> instructions till I send a 'SHUTDOWN' command upon which it should shut
> down.
>
> When I run this program and suppose send 'MaxSim' to it, it launches
> notepad.exe fine, but then after that it doesn't accept subsequent
> command. I want is that it should accept subsequent commands like
> Driving Sim and launch windows explorer etc untill I send a 'SHUTDOWN'
> command.
>
> Any help on this, it will be greatly appreciated.

--
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list