How can I get results from exec()?
Any suggestions appreciated!!!
#!/usr/bin/python
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
host = socket.gethostname()
port = 1234
sock.bind((host,port))
while True:
cmd, addr = sock.recvfrom(1024)
if len(cmd) > 0:
print("Received ", cmd, " command from ", addr)
exec(cmd) # here how I can get results?
print( "results:", <for example results printed here> )
sock.close()