ARTICLE AD BOX
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:
<tr> <td><button><a href="scripts/wol.php"><img src="images/action_start.jpg" alt="Computer 2" style="width:50px;"></a></button> </tr>PHP code:
<?php system ("python /var/www/html/scripts/python/wake.py8 [Variable1] [Variable2]"); header ("Location:index.html"); ?>Python:
#!/usr/bin/python3 import socket import sys import codecs if len(sys.argv) < 3: print ("Usage: wake.py <BROADCAST Address> <MAC Address>") 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))124k31 gold badges285 silver badges492 bronze badges
New contributor
Pixelworks is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
