0
我試圖運行一個python腳本來向我的網絡上的計算機發送一個魔法數據包。它適用於其他計算機,但是當我嘗試使用自己的MAC地址運行腳本時,出現錯誤。WOL MAC地址不起作用
這是我的Python腳本
#!/usr/bin/env python
#Wake-On-LAN
#
# Copyright (C) 2002 by Micro Systems Marc Balmer
# Written by Marc Balmer, [email protected], http://www.msys.ch/
# This code is free software under the GPL
import struct, socket
def WakeOnLan(ethernet_address):
# Construct a six-byte hardware address
addr_byte = ethernet_address.split(':')
hw_addr = struct.pack('BBBBBB', int(addr_byte[0], 16),
int(addr_byte[1], 16),
int(addr_byte[2], 16),
int(addr_byte[3], 16),
int(addr_byte[4], 16),
int(addr_byte[5], 16))
# Build the Wake-On-LAN "Magic Packet"...
msg = b'\xff' * 6 + hw_addr * 16
# ...and send it to the broadcast address using UDP
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.sendto(msg, ('10.0.0.129', 9))
s.sendto(msg, ('10.0.0.129', 7))
s.close()
# Example use
WakeOnLan('30-5A-3A-03-82-AE')
隨着10.0.0.129是我的本地地址和30-5A-3A-03-82-AE是我的物理地址。
當我嘗試運行腳本,我得到這個錯誤
Traceback (most recent call last):
File "C:\xampp\htdocs\wol\wolme.py", line 35, in <module>
WakeOnLan('30-5A-3A-03-82-AE')
File "C:\xampp\htdocs\wol\wolme.py", line 15, in WakeOnLan
hw_addr = struct.pack('BBBBBB', int(addr_byte[0], 16),
ValueError: invalid literal for int() with base 16: '30-5A-3A-03-82-AE'
同樣,沒有其他計算機都有這個問題。任何幫助讚賞。
天啊。我很愚蠢。我怎麼沒有看到這個。謝謝! –