I'm trying to use xinetd to remotely run a command (traccejob). When I connect through telnet, everything works fine. Unfortuantely, the client that I've written doesn't seem to receive the data from the server. The code looks like:
server:
import sys
import commands
def main():
tjinput = sys.stdin.readline().strip()
(ret, out) = commands.getstatusoutput('/usr/bin/tracejob '+tjinput)
print out
sys.stdout.flush()
if __name__ == "__main__":
main()
client:
host = 'xxx.xxx.xxx.xxx'
port = 12345
import socket
import sys
def main(argv):
message = 'hello'
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.connect((host, port))
sock.send(message)
data = sock.recv(1024)
sock.close()
print repr(data)
if __name__ == '__main__':
main(sys.argv)
The client process stops on the sock.recv(1024) line. I can't for the life of me tell why sock.recv isn't reading the output from the socket. Probably a coding issue? If it helps, the xinetd.d file looks like this:
service tracejob
{
flags = IPv4
disable = no
socket_type = stream
wait = no
user = root
group = root
server = /usr/local/bin/tracejob_xinetd.py
port = 12345
type = UNLISTED
}
where tracejob_xinetd.py is the server described above.
Any tips? Thanks in advance.