Wake remote sleeping Mac for disk connection
Allow the ssh connection to automatically wake a remote machine, with the appropriate parameters, to establish a connection to the disks.
When the "Wake on ethernet network administrator access" option in the system prefs is selected, a remote Mac can be awakened by a specially formed "magic packet". This packet can be generated (for example) by the following script:
#! /usr/bin/env python
# Copyright (C) 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 time, struct, socket, commands
def WakeOnLan(ethernet_address, hostname):
ipaddr=commands.getoutput('host %s' % hostname).split()[-1]
print ipaddr
# 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, (ipaddr, 9))
s.close()
# Example use
#time.sleep(60)
WakeOnLan('FF:FF:FF:FF:FF:FF','me.site.org')
The user would have to supply the MAC address of the machine to be able to do this trick. The IP address should be determined via DNS lookup.
When the "Wake on ethernet network administrator access" option in the system prefs is selected, a remote Mac can be awakened by a specially formed "magic packet". This packet can be generated (for example) by the following script:
#! /usr/bin/env python
# Copyright (C) 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 time, struct, socket, commands
def WakeOnLan(ethernet_address, hostname):
ipaddr=commands.getoutput('host %s' % hostname).split()[-1]
print ipaddr
# 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, (ipaddr, 9))
s.close()
# Example use
#time.sleep(60)
WakeOnLan('FF:FF:FF:FF:FF:FF','me.site.org')
The user would have to supply the MAC address of the machine to be able to do this trick. The IP address should be determined via DNS lookup.
2
people like this idea
I like this idea!
Tell me when this idea gets some attention.
The more people who like this idea, the more it gets noticed.
The more people who like this idea, the more it gets noticed.
-
Inappropriate?We're unlikely to add this into the program itself, but it'd be relatively easy to accomplish with our applescript interface
http://www.magnetk.com/support/expand...
Loading Profile...






EMPLOYEE
