Skip to content

Instantly share code, notes, and snippets.

@iandexter
Created July 3, 2013 03:12
Show Gist options
  • Save iandexter/5915158 to your computer and use it in GitHub Desktop.
Save iandexter/5915158 to your computer and use it in GitHub Desktop.
Simple XML-RPC server/client for remote execution of system calls.
#!/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])
#!/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