-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremoteclient.py
More file actions
50 lines (41 loc) · 1.1 KB
/
remoteclient.py
File metadata and controls
50 lines (41 loc) · 1.1 KB
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
#! /usr/bin/python
import socket,sys
x=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
ip=sys.argv[1]
port = 12345
x.sendto("wanna connect",(ip,port))
def sendreceive():
login_req=x.recvfrom(100)
print login_req[0]
usr=x.recvfrom(100)
print usr[0]
username=raw_input()
x.sendto(username,(ip,port))
passwordprompt=x.recvfrom(100)
print passwordprompt[0]
password=raw_input()
x.sendto(password,(ip,port))
def logic():
while 1:
command=raw_input("enter your command: ")
x.sendto(command,(ip,port))
print "======================="
commout=x.recvfrom(100)
print command
print "after execution: "
print commout[0]
def sender():
response=x.recvfrom(10)
if response[0]== "ok" :
x.sendto("let's start",(ip,port))
sendreceive()
confirmation=x.recvfrom(40)
print confirmation[0]
if confirmation[0]== "start" :
logic()
else:
sendreceive()
else:
print "connection refused by server"
sender()
x.close()