Wake from sleep

Hi,

Is there a way to have an applescript program run while the computer is sleeping?

Thanks,

Model: MacBook Pro
AppleScript: 2.2.3
Browser: Safari 536.26.17
Operating System: Mac OS X (10.8)

When it sleeps it sleeps, but you could have run a script or something from a networked computer, and have yours wake up on lan.

The other option is to wake it up via the battery settings, and then run something as the computer wakes up. There is at least one utility that is free that enables you to run stuff when the computer wakes up.

It’s called Scenario

I wonder what that wake for network does to wake the computer.

Hi Adam,

I was reading about that app last night.

Hello.

SleepWatcher also wakes your computer up from sleep. you can find it here..

I think there is to waking your computer up from sleep is to send an ip-packet to its ip-address. The network stack will then, if so configured (Battery settings), wake the computer up, by generating an interrupt or exception that orders the computer to wake up.

Wasn’t there a way to run a script in the pram before?

Hello.

I don’t know, I started out with Tiger. I used to have an alarm fire off a minute or two after having awakened it, from iCal. You can of course make it happen other ways. As you also can set the wake up time from launchCtl (I think).

You can set a wakeup time in System Preferences > Energy Saver > Schedule Button

Hi McUsrII,

I was thinking. Is it really bad if the machine never goes into computer sleep?

Thanks,

I use a program called ShareTool to reach my home machine from my Laptop via a secure tunnel when I’m away. While “wake on LAN” works within a LAN, I don’t know of any way to wake an interior machine from the outside through your router. (ShareTool provides a menu command: "Keep machine awake). You can also use software like Caffeine to do it. I’ve left my machine running and awake for weeks at a time. The screens sleep, but the CPU doesn’t. I’ve been doing that for years and never noticed any adverse effect. Caffeine is scriptable, by the way, at least as far as turning it on and off.

Hello.

There are many ways to achieve this, but you can’t run from the fact that at least one machine has to be awake behind your router. Or, you can dedicate/configure ports and static ip - addresses so it is publically availiable through the router and nat.

(I think julio’s mail commander could be used in such a scheme, so that you could wake up your wanted computer by mail! )

Many that are protective of their hard-drives, uses a kind of DMZ scheme, where you tell one computer behind your router to wake the other up with ssh and certicates. Then you access that computer from the outside with ssh and certificates. Guys who needs to have it like that, has probably too much going on that can hang and make the cpu heat up. :slight_smile:

Joke aside, that is the secure version, but for normal deadly people I think Adams’s scheme with ssh suffices.

Second thoughts:
It also depends on what kind of subnet you are on. If you are sitting directly on a public subnet, sharing the gateway with lots of people that can sniff your packets, then the risk is much higher.

Hi,

I think I’ll create a script app, that sets the computer to wake up 1 minute before the first detected notification somehow. The notification center app seems to work erratically, so I’ll have to work on it. I might end up limiting the computer to display sleep as Adam suggested.

Thanks a lot,

Model: MacBook Pro
AppleScript: 2.2.3
Browser: Safari 536.26.17
Operating System: Mac OS X (10.8)

My suggestion resulted from many hours of failed attempts to manage any other way, Kel, and bear in mind that Wake on LAN works fine from within your LAN, so testing a new scheme requires doing so from outside the LAN.

Hi,

I’ve been doing some research on this and found that launchd can run a script while the system is asleep. There must be some limitations with this that I haven’t read about. Can it use osascript to run an applescript while the system is asleep?

Model: MacBook Pro
AppleScript: 2.2.3
Browser: Safari 536.26.17
Operating System: Mac OS X (10.8)

Hello.

I think you are misinformed, what launchd will do, is run your script, after it has woken up, if the script should have been triggered while your machine slept.

And yes, you can run osascript from a launchd process, but I think you won’t get in touch with the UI, display dialogs and such. Last time I did that, I had an applet I called from my osascript to take care of business for me.

This is how things workes on Snow Leopard, I have a hard time believing that they would let a launchd process awake the machine from sleep for a whole slew of reasons, security concerns being one of them.

Hi,

I got it from this blog:

http://nb.nathanamy.org/2012/07/schedule-jobs-using-launchd/

I thought it was from Apple developer site.

Hello.

He states the same as I said in his blog

It is time for me to get some sleep. I’d rather not recommend anything that has to do with network security. Personally I’d go for Adam’s solution if you don’t reside on a University network or something like it. :slight_smile:

But you should then have the full overview of what kind of processes you have installed, and whether some of them can hang and harm your computer. If you haven’t customized the processes your machine are running a whole lot, then Adam’s way of doing it, is perfectly sound and safe.

Nathan’s remarks seem contradiction, but the last line brought hope.

It’s probably not true otherwise I would have found more info on it.

Editted:

BTW, back to the old plan of waking the computer before a notification. I was thinking of using pmset. Before the system goes to sleep I would need to get events from Calendar and reminders from Reminders. Then, wake the system just before the alarms set to go off.

Thanks,

Hello.

I interpret it to say that he can have scheduled jobs, but doesn’t have to consider that fact and keep his computer awake at all times.

I think there are utilites to use that can track the computer goes to sleep event, but personally I’d just use a script for it, that sets up the awakening moment for the computer and all that. :slight_smile: