how to get results from exec() in python 3.1?
#!/usr/bin/python
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
host = socket.gethostname()
port = 1234
sock.bind((host,port))
ret_str = "executed"
while True:
cmd, addr = sock.recvfrom(1024)
if len(cmd) > 0:
print("Received ", cmd, " command from ", addr)
exec(cmd) # here I need execution results returns to ret_str
print( "results:", ret_str )