-
Notifications
You must be signed in to change notification settings - Fork 37
/
open_light.py
39 lines (33 loc) · 998 Bytes
/
open_light.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
# telnet program example
import socket, select, string, sys
import time
import os
def prompt() :
print("333")
sys.stdout.write('<You> ')
sys.stdout.flush()
#main function
if __name__ == "__main__":
# if(len(sys.argv) < 3) :
# print ('Usage : python telnet.py hostname port')
# sys.exit()
host = "www.bigiot.net"
port = 8181
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(2)
# connect to remote host
try :
s.connect((host, port))
except :
print ('Unable to connect')
sys.exit()
print ('Connected to remote host. Start sending messages')
checkinBytes=bytes('{\"M\":\"checkin\",\"ID\":\"2068\",\"K\":\"7b0361f93\"}\n')
s.sendall(checkinBytes)
time.sleep(1)
checkinBytes=bytes('{\"M\":\"say\",\"ID\":\"D2315\",\"C\":\"stop\"}\n')
s.sendall(checkinBytes)
time.sleep(1)
# os.system("mplayer wav/open_light.mp3")
prompt()
s.close()