blob: 8333d3989751fc857767aec4b767c16ce5b9cf8b [file] [log] [blame]
Guido van Rossumf06ee5f1996-11-27 19:52:01 +00001#! /usr/bin/env python
Guido van Rossum4e620371995-04-10 11:46:03 +00002
3# Remote python client.
4# Execute Python commands remotely and send output back.
5
6import sys
7import string
8from socket import *
9
10PORT = 4127
11BUFSIZE = 1024
12
13def main():
Tim Peterse6ddc8b2004-07-18 05:56:09 +000014 if len(sys.argv) < 3:
15 print "usage: rpython host command"
16 sys.exit(2)
17 host = sys.argv[1]
18 port = PORT
19 i = string.find(host, ':')
20 if i >= 0:
21 port = string.atoi(port[i+1:])
22 host = host[:i]
23 command = string.join(sys.argv[2:])
24 s = socket(AF_INET, SOCK_STREAM)
25 s.connect((host, port))
26 s.send(command)
27 s.shutdown(1)
28 reply = ''
29 while 1:
30 data = s.recv(BUFSIZE)
31 if not data: break
32 reply = reply + data
33 print reply,
Guido van Rossum4e620371995-04-10 11:46:03 +000034
35main()