Reputation: 11
I am newbie to python, using wxpython i have made a GUI model ,which does certain operation on local machine. I want that tool do operation on multiple local system from remote client. i have gone through few docs(python :Networking) but i could not understand :(. My requirements are user should provide IP address of each(any number of machine) machine and also port number. And without doing ssh it should happen. can anybody please suggest me the solution in python ?I am trying it from last 3 days.
Upvotes: 0
Views: 1473
Reputation: 1531
I had same problem a few years ago, and i solved it with Python Pyro (http://pythonhosted.org/Pyro4/), It is a library that enables you to build applications in which objects can talk to each other over the network, with minimal programming effort and simply.
You can use Client/Server Client/Client, etc. and you can execute "things" or do "something" in remote network computers.
For instance, if you have to send a message
to one PC, or send a File
, or execute class
remote, etc.
Full Example:
SERVER
# saved as greeting.py
import Pyro4
class GreetingMaker(object):
def get_fortune(self, name):
return "Hello, {0}. Here is your fortune message:\n" \
"Tomorrow's lucky number is 12345678.".format(name)
greeting_maker=GreetingMaker()
daemon=Pyro4.Daemon() # make a Pyro daemon
ns=Pyro4.locateNS() # find the name server
uri=daemon.register(greeting_maker) # register the greeting object as a Pyro object
ns.register("example.greeting", uri) # register the object with a name in the name server
print "Ready."
daemon.requestLoop() # start the event loop of the server to wait for calls
CLIENT
# saved as client.py
import Pyro4
name=raw_input("What is your name? ").strip()
greeting_maker=Pyro4.Proxy("PYRONAME:example.greeting") # use name server object lookup uri shortcut
print greeting_maker.get_fortune(name)
Firstly you have to run server (for instance on IP local or whatever), and it will be waiting for request, and if you run then client, you will see how it works (must know where connect, IP Server [or Domain])
You can do everything on Server and call it from other PC on Network or on Internet.
It's very usefull for your appliance.
I hope it help you.
(Documentation link: http://pythonhosted.org/Pyro4/intro.html#simple-example)
Upvotes: 1
Reputation: 3948
There is no one solution to this.
You will need to use a client server model. Your client will be similar to what you have now and the server will control this. Look into Twisted for the networking it will probably be easier than raw sockets.
There is no way to run remote commands without having access to that box.
Regards
Upvotes: 0