Wake Up and Put to Sleep a remote computer on a LAN

I need to be able to wake up a computer on my home network, perform a back up of that machine to an external HD and then put that computer back to sleep when finished.

I know that Wake550 will wake up remote machines, but it won’t put a remote machine to sleep.

I don’t need a “secure” solution. This is for my home network of 3 Macs (20" G5 iMac, 15" G4 iMac & eMac). The G5 is the machine that will be performing the backup of the other machines (the eMac at the very least – it’s my wife’s machine).

I can get the machines’ MAC addresses from System Preferences. I would like to know how to that in code (as a learning experience).

OS: 10.4.2

Any help is greatly appreciated,
Brad Bumgarner, CTA

If you have a way to wake the machine, you’re done - it will go back to sleep according to its energy saver preferences.

I would like to do everything through a script. The backup takes a LONG time. Longer than Energy Saver allows. So I’d like to run a script that will will wake the other computer(s) on the LAN, run the back up, and then put everything to sleep.

I have tried some of this earlier.
Setting machines asleep shouldn’t be difficult:

tell application "Finder" of machine "eppc://yourname:passw@192.168.1.x" to sleep

(enabled remote apple events in Sharing Prefpane and triggered after your backup finishes)
However, waking networked machines up in a reliable manner is what broke me up.
Wake550 isn’t scriptable and you will need a macro editor such as Quickeys to control its buttons, which isn’t very reliable by itself.
My biggest issue however was that setting up machines to be wakened via the network, would lead to spurious wakeups that happen anytime (day or night). This may be caused by my network setup (airport, router, internet access)

I don’t know how to do this to a network machine, but assuming you can get the machine’s attention, running this on that machine will keep the machine awake using Jiggler: http://www.sticksoftware.com/software/Jiggler.html, which is a little application that keeps the screen saver from activating by creating events.

tell application "Finder" to run application "Jiggler" -- no screensaver will happen
-- setting spindown to 0 and dim to 0 prevents the disk and display from sleeping
do shell script "sudo pmset spindown 0 dim 0" password "your.PW.here" with administrator privileges
-- the following shell script spins up a sleeping drive which takes a while, so wait for it before doing something else.
do shell script "diskutil info \"POSIX path to disk\" > /dev/null"

When you’ve done your backup, running this script on the wakened machine will let it go back to sleep:

tell application "Finder"
	try
		quit application "Jiggler"
	on error return
	end try
end tell
tell application "ScreenSaverEngine" to activate -- screensaver will start
-- setting spindown to 1 and dim to 1 will sleep the screen and HD in 1 minute - the shortest possible setting.
do shell script "sudo pmset dim 1 spindown 1" password "your.PW.here" with administrator privileges

Note that I never let the CPU sleep - it’s set to never in the Energy Saver Preference Panel and I never reset it.
I think you’ll have to do the same so you can speak to the machine remotely. Someone with experience will have to tell you how to start an AppleScript on a remote machine - I’ve never done it.

I guess we have a nomenclature misalignment here.
(1) SYSTEM sleep is a state where the processor itself is in sleep - which can be reactivated (as network packets are still detected) via the network circuitry. Wake550 makes use of that.
(2) DISPLAY & INTERNAL DRIVE sleep is a state where the machine still runs and will react on any incoming (mouse, keyboard, network, USB, FireWire) signal.

If DISPLAY & INTERNAL DRIVE sleep is sufficient here, there is no (SYSTEM) wake-up issue and the orig. problem may be solved.

(btw launching a remote Applet will require something like:

tell application "Finder" of machine "eppc://yourname:passw@192.168.1.x" to open file (PATHtoAPPLET) 

Thank you both for your ideas. This should allow me to get started on what I’d like to accomplish.