-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
executable file
·64 lines (36 loc) · 857 Bytes
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/local/bin/python3
# Things that we might need to change
serverhost = 'localhost'
port = 9020
import os
import sys
import subprocess
import socket
import string
import time
#sys.stdin.close()
#sys.stdout.close()
#sys.stderr.close()
def sendline(line):
msg = line + "\n"
bstr= bytes(msg, 'utf-8')
socket.sendall(bstr)
# get userid
output = subprocess.run('whoami',shell=1, stdout=subprocess.PIPE)
ooo = output.stdout
who = ooo.decode()
who = who.rstrip()
# connect to server
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.connect((serverhost, port))
# send information to server
i = 1
print("\nEnter up to 10 lines('.' to quit):\n\n")
while i < 11:
print(str(i) + ": " , end = '')
line = input()
line.rstrip()
if line == '.':
break
sendline(line)
i += 1