0

I'm relatively new to Python and I don't understand why the same script doesn't run on my RS1221+ NAS but does on the QNAP ts-219p ii without problems. It's a WoL script designed to turn on specific PCs via an HTML page. You press on a PNG image which then calls a php script which then calls said Python script.

I simply copied the php and python script from my colleague. It works on the QNAP ts-219p NAS system but not on the newer RS1221+. Following packages are already installed on the new system: Python 3.9, Node.js v 18 and php 8.0.

In Web Station on the RS1221+ Python is activated and shows green. The module "wakeonlan" version 3.0.0 is also installed in the "edit" section.

This is the php script that calls the python script (with the x's being placeholders and changed for the Mac of the PC I want to turn on). My Network Address is 192.168.0.1 /23:

<?php
system ( "python wake.py 192.168.1.255 XX:XX:XX:XX:XX:XX");
header ("Location:index.html");
?>

This is the python script (wake.py) I'm using for WoL thats called and should run on the server:

import socket
import sys
 
if len(sys.argv) < 3:
    print("Usage: wakeonlan.py <ADR> <MAC>     (example: 192.168.1.255 00:11:22:33:44:55)")
    sys.exit(1)
 
mac = sys.argv[2]
data = ''.join(['FF' * 6, mac.replace(':', '') * 16])
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.sendto(data.decode("hex"), (sys.argv[1], 9))

I've already tried changing the Python script to use another module:

from wakeonlan import send_magic_packet

send_magic_packet('XX-XX-XX-XX-XX-XX')

but this didn't work either. As I said, I'm not a master in python and thats why I would be thankful for all suggestions.

Jay
  • 1
  • 4
  • First, Does WOL work with a command like [wolcmd](https://www.depicus.com/wake-on-lan/wake-on-lan-cmd)? – Corralien Jan 24 '23 at 09:34
  • Yes, but I want to do it with a python script on a synology nas server with linux (Version: DSM 7.1.1 Update 2). It works fine on the console. – Jay Jan 24 '23 at 10:11
  • Try this script https://github.com/multipetros/wol.py/blob/master/wol.py, it works for my synology. – Corralien Jan 24 '23 at 10:25
  • I've tried it for a few hours now. I'm just gonna let it run on the old system for a bit longer and figure a way out. Maybe setting it up on a rasberry or taking one process away from another server for a web service. But thanks for the suggestions :) – Jay Jan 24 '23 at 13:25

1 Answers1

0

For anyone comming back to this problem:

Using this https://pypi.org/project/wakeonlan/ package for Python solved all my problems I had.

Jay
  • 1
  • 4
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/34241745) – Anonymous Apr 21 '23 at 15:28