Wake-on-lan script working but browser jumps to 404 after execution
I built an HTML page on Apache that contains a python script called from PHP to wake-on-lan my domain devices.
The script works fine and the devices start as designed, but after clicking on the wake-on-lan button the html page jumps to a 404 error page. Is there a way to avoid this?
html snippet:
PHP code:
Python:
#!/usr/bin/python3
import socket
import sys
import codecs
if len(sys.argv) < 3:
print ("Usage: wake.py ")
sys.exit(1)
mac = sys.argv[2]
data = ''.join(['FF' * 6, mac.replace(':', '') * 16])
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
decode_hex = codecs.getdecoder("hex_codec")
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.sendto(decode_hex(data)[0], (sys.argv[1], 9))