Created
July 3, 2013 03:12
-
-
Save iandexter/5915158 to your computer and use it in GitHub Desktop.
Simple XML-RPC server/client for remote execution of system calls.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -* | |
""" | |
Client for demonstrating XML-RPC Python calls. | |
""" | |
import xmlrpclib, sys | |
server_url = 'http://localhost:8888' | |
server = xmlrpclib.ServerProxy(server_url) | |
print server.getListings(sys.argv[1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Simple XML-RPC server for remote execution of system calls. | |
""" | |
import subprocess, SimpleXMLRPCServer | |
server_host = 'localhost' | |
server_port = 8888 | |
# Methods go here. | |
class SystemCalls: | |
def getListings(self, curr_dir): | |
listing = subprocess.Popen([r'ls','-l',curr_dir], stdout=subprocess.PIPE).communicate()[0] | |
print listing | |
"""Instantiate object""" | |
syscall_obj = SystemCalls() | |
server = SimpleXMLRPCServer.SimpleXMLRPCServer((server_host, server_port)) | |
server.register_instance(syscall_obj) | |
print "Listening on %s, port %s" % (server_host, server_port) | |
"""Loop until killed""" | |
server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment