Author Topic: Wake On Lan (wol) Magic Packet  (Read 4374 times)

clofland

  • Full Member
  • ***
  • Posts: 245
    • View Profile
    • http://www.lofland.net/
Wake On Lan (wol) Magic Packet
« on: February 19, 2010, 05:00:15 pm »
Anyone know how to send a WOL Magic Packet from a Zaurus?
[span style=\'font-size:14pt;line-height:100%\']C-760 pdaXrom 1.1.0beta3[/span]
- Sandisk UltraII 1GB SD card - Socket LP CF LAN card - Socket LP CF WLAN card - Socket CF Bluetooth Card Rev H -

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
Wake On Lan (wol) Magic Packet
« Reply #1 on: February 20, 2010, 05:01:58 pm »
I believe hping2 can do WOL. A quick Google seems to imply there are binaries/packages floating around.
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

clofland

  • Full Member
  • ***
  • Posts: 245
    • View Profile
    • http://www.lofland.net/
Wake On Lan (wol) Magic Packet
« Reply #2 on: February 26, 2010, 12:04:53 pm »
Quote from: clofland
Anyone know how to send a WOL Magic Packet from a Zaurus?

To answer my own question (because I hate it when I find questions with no answers).

This works:
http://gsd.di.uminho.pt/jpo/software/wakeo...o/wolpython.txt

(And a copy in case the above URL dies before this forum does)
# Wake-On-LAN
#
# Copyright © 2002 by Micro Systems Marc Balmer
# Written by Marc Balmer, marc@msys.ch, 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 = '\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, ('<broadcast>', 9))
  s.close()

# Example use
WakeOnLan('0:3:93:81:68:b2')

As long as you have python installed, this works great. Just replace the MAC after the last line with the one you want to wake up.

Very nice. Now I can shut all of the computers in my house off (or put them to sleep) and use my Z to turn them on when I need to access them.
[span style=\'font-size:14pt;line-height:100%\']C-760 pdaXrom 1.1.0beta3[/span]
- Sandisk UltraII 1GB SD card - Socket LP CF LAN card - Socket LP CF WLAN card - Socket CF Bluetooth Card Rev H -