-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPJLink.cgi
51 lines (42 loc) · 1.4 KB
/
PJLink.cgi
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
#!/usr/bin/python3
# use this python script in a cgi or www directory to operate a Panasonic PJLink projector
# you can add arguments and variables to make it easier. Panasonic PJLink default port is 4352, it can be changed through the menu tree in the projector
# basic command from URL to turn on projector using this cgi python script: '[server IP Address]/[cgi or whatever sub www directory in your control server]/PJlink.cgi?PJon'
# important note: projector must have no password to at least one of the 'user' or 'admin' logins, or else the data sent will require matched encryption
import cgitb
import time
import socket
import sys
cgitb.enable()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = '[Projector IP Address]'
PORT = 4352
cmd = sys.argv[1]
# to control more than one projector, add a second argument and define variables as the IP Addresses or names of the projector as
# they would appear in DNS
print("content-type: text/html\r\n\r")
if cmd == 'PJon':
data = '%1POWR 1' + '\r'
s.settimeout(2)
time.sleep(0.2)
s.connect((HOST, PORT))
ack = s.recv(PORT)
print(ack)
s.sendall(data.encode())
msg = s.recv(PORT)
print(msg)
s.close()
elif cmd == 'PJoff':
data = '%1POWR 0' + '\r'
s.settimeout(2)
time.sleep(0.2)
s.connect((HOST, PORT))
ack = s.recv(PORT)
print(ack)
s.sendall(data.encode())
msg = s.recv(PORT)
print(msg)
s.close()
else:
print('no match for command')
quit()