1+ # # client.py
2+ # # import socket
3+
4+ # import subprocess
5+
6+ # from threading import Thread
7+ # from time import sleep
8+
9+
10+ # # s = socket.socket()
11+ # # s.connect(('localhost', 1337))
12+ # popen = None
13+
14+ # def execute(cmd):
15+ # print ("im here")
16+ # popen = subprocess.Popen(cmd,
17+ # stdin=subprocess.PIPE,
18+ # stdout=subprocess.PIPE, universal_newlines=True)
19+ # for stdout_line in iter(popen.stdout.readline, ""):
20+ # yield stdout_line
21+ # popen.stdout.close()
22+ # return_code = popen.wait()
23+ # if return_code:
24+ # raise subprocess.CalledProcessError(return_code, cmd)
25+
26+ # # Example
27+
28+ # def output_loop():
29+ # for path in execute(["python"]):
30+ # print(path, end="")
31+
32+ # # Example
33+ # # await execute("python")
34+ # # print(path, end="")
35+
36+ # if __name__ == "__main__":
37+
38+ # input ("First input")
39+
40+ # thread = Thread(target = output_loop)
41+
42+
43+ # thread.start()
44+ # thread.join()
45+
46+ # sleep(2)
47+ # # popen.communicate(str(input("I am here")).encode('utf-8'))
48+ # popen.stdin.write(str(input("I am here").encode('utf-8')))
49+ # sleep(2)
50+
51+ # print("thread finished...exiting")
52+
53+
54+ # # popen = subprocess.Popen(['python',], stdout=subprocess.PIPE, universal_newlines=True)
55+ # # for stdout_line in iter(popen.stdout.readline, ""):
56+ # # yield stdout_line
57+ # # popen.communicate(str(input()).encode('utf-8'))
58+ # # popen.stdout.close()
59+
60+ # # while (process.wait()):
61+ # # process.communicate(str(input()).encode('utf-8'))
62+
63+
64+
65+ #from subprocess import Popen, PIPE
66+
67+ #p1 = Popen(['python'],stdin=PIPE, stdout=PIPE)
68+ # # p2 = Popen(['sed', '/^$/d'], stdin=p1.stdout, stdout=PIPE)
69+ # # p3 = Popen(['awk', 'NR > 1 { print $2 }'], stdin=p2.stdout, stdout=PIPE)
70+
71+ #p1.stdin.write("print('hello world!')".encode('utf-8'))
72+
73+ #p1.wait()
74+ # stdout, _ = p1.communicate()
75+
76+
77+
78+
79+
80+ #!/usr/bin/env python3
81+ import time
82+ #from subprocess import Popen, PIPE
83+ import subprocess
84+
85+ proc = subprocess .Popen ("python" , stdin = subprocess .PIPE )
86+ #while (proc.poll() is None):
87+ proc .stdin .write ("print('hello world!!')" .encode ('utf-8' )) # etc
88+ #time.sleep(4)
0 commit comments