Network Programming in Python

D

diffuser78

I am a newbie in python. I want to learn and implement a small
networking concept. Please help me. Every help is appreciated.

I have one Linux Box and one Windows PC. I want to have a daemon
running on Windows PC which listens on some specicif port number. I
want to send a TCP/IP or UDP/IP packet from Linux box to Windows PC to
start some application. As Windows PC recieves such a packet from Linux
Box it executes a certain .exe file. I want to implement this concept.

In short I want to remotely send command from Linux to Windows PC to
start a particular application.

Thanks, Every help is appreciated.
 
F

Fredrik Lundh

I am a newbie in python. I want to learn and implement a small
networking concept. Please help me. Every help is appreciated.

I have one Linux Box and one Windows PC. I want to have a daemon
running on Windows PC which listens on some specicif port number. I
want to send a TCP/IP or UDP/IP packet from Linux box to Windows PC to
start some application. As Windows PC recieves such a packet from Linux
Box it executes a certain .exe file. I want to implement this concept.

In short I want to remotely send command from Linux to Windows PC to
start a particular application.

server:

http://docs.python.org/lib/module-SimpleXMLRPCServer.html

client:

http://docs.python.org/lib/module-xmlrpclib.html

</F>
 
D

diffuser78

Thanks...I will read that up...could you give me some more headstart or
if you any sample code which I can study.

Thanks for your help, every help is appreciated
 
F

Fredrik Lundh

Thanks...I will read that up...could you give me some more headstart or
if you any sample code which I can study.

both chapters I pointed you to contain examples.

</F>
 
D

diffuser78

I have Python 2.4.2 on windows and Linux both. I got an import error.
how can we obtain the twisted libraries ?



When I try to run your code
Jean-Paul Calderone said:
I am a newbie in python. I want to learn and implement a small
networking concept. Please help me. Every help is appreciated.

I have one Linux Box and one Windows PC. I want to have a daemon
running on Windows PC which listens on some specicif port number. I
want to send a TCP/IP or UDP/IP packet from Linux box to Windows PC to
start some application. As Windows PC recieves such a packet from Linux
Box it executes a certain .exe file. I want to implement this concept.

In short I want to remotely send command from Linux to Windows PC to
start a particular application.

Thanks, Every help is appreciated.

Untested:

from twisted.internet import protocol, reactor
from twisted.protocols import basic

COMMANDS = {
"xterm": ("/usr/bin/xterm", {"DISPLAY": ":1.0"}),
}

class CommandLauncher(basic.LineReceiver):
def lineReceived(self, line):
try:
cmd, env = COMMANDS[line]
except KeyError:
self.sendLine("error")
else:
reactor.spawnProcess(None, cmd, env=env)
self.sendLine("okay")

f = protocol.ServerFactory()
f.protocol = CommandLauncher
reactor.listenTCP(12345, f)
reactor.run()

You should be able to telnet to this (port 12345) and type in
names of commands for it to run. Of course, xterm isn't a very
good win32 program to run but I couldn't think of a better example.
You could also write a program to send command requests to this
server, instead of using telnet.

Jean-Paul
 
I

Irmen de Jong

Really, was that so hard?

Python makes sockets a total breeze. You can write an 80's style HTTP
server in less than a page of code.

But making a *good* 80's style http/socket server is a lot of work.
Better pick one of the high level protocols built on top of it,
to shield you from the gory details of raw socket programming.

--Irmen
 
D

diffuser78

I got it ...initially sourceforge page linked all old libraries..later
then got this link to twistedmatrix. Thanks.
 
B

Bruno Desthuilliers

(e-mail address removed) a écrit :
I have Python 2.4.2 on windows and Linux both. I got an import error.
how can we obtain the twisted libraries ?

Is google down ?
 
B

Bill Maxwell

I am a newbie in python. I want to learn and implement a small
networking concept. Please help me. Every help is appreciated.

I have one Linux Box and one Windows PC. I want to have a daemon
running on Windows PC which listens on some specicif port number. I
want to send a TCP/IP or UDP/IP packet from Linux box to Windows PC to
start some application. As Windows PC recieves such a packet from Linux
Box it executes a certain .exe file. I want to implement this concept.

In short I want to remotely send command from Linux to Windows PC to
start a particular application.


Have you checked out Pyro (Python Remote Objects)?

http://pyro.sourceforge.net/

Bill
 
G

Grant Edwards

.
.
.
A misreading of "Pyro". Pyro <URL: http://pyro.sourceforge.net/ >,
of course, is yet another communications layer, but, as was suggested,
one that might particularly suit Mr. Johnson.

Ah! I think I've always mixed up pyrex and pyro and psco, and
never actually new what Pyro really was. I've got it straight
now (how long I'll keep the three of them striaght in my head
is another question).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top