I run a scheduled Applescript through iCal to start up a torrent app at 1am and stop it at 6am every day but when I come back to the machine it has nearly always failed to start.

I suspect this is related to coming out of sleep mode because it works fine when I run the script manually.

Is there a trick to get the mac out of sleep, wait for it to be responsive then start the app reliably? I there another problem I need to solve?