]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Demo/sockets/rpython.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Demo / sockets / rpython.py
CommitLineData
4710c53d 1#! /usr/bin/env python\r
2\r
3# Remote python client.\r
4# Execute Python commands remotely and send output back.\r
5\r
6import sys\r
7import string\r
8from socket import *\r
9\r
10PORT = 4127\r
11BUFSIZE = 1024\r
12\r
13def main():\r
14 if len(sys.argv) < 3:\r
15 print "usage: rpython host command"\r
16 sys.exit(2)\r
17 host = sys.argv[1]\r
18 port = PORT\r
19 i = string.find(host, ':')\r
20 if i >= 0:\r
21 port = string.atoi(port[i+1:])\r
22 host = host[:i]\r
23 command = string.join(sys.argv[2:])\r
24 s = socket(AF_INET, SOCK_STREAM)\r
25 s.connect((host, port))\r
26 s.send(command)\r
27 s.shutdown(1)\r
28 reply = ''\r
29 while 1:\r
30 data = s.recv(BUFSIZE)\r
31 if not data: break\r
32 reply = reply + data\r
33 print reply,\r
34\r
35main()\r