Applescript for 7 year Installation!
Applescript for 7 year Installation!
- Subject: Applescript for 7 year Installation!
- From: Christopher McClelland <email@hidden>
- Date: Tue, 14 Jun 2005 13:24:54 +0100
Hi,
We are working on an installation that requires the loading of a file at random times during a 6 am to midnight day, everyday, for the next 7 years! This 18 hour day is divided into 5 time zones where different files are selected according to the time zone it is in.
We are using OS X's scheduling to turn on the computer every morning at 6am and we have placed an applescript in the startup folder.
The applescript (see below) does the following:
1. Check the current time & decide what time zone it is in e.g. 3pm -> C
2. Select a random file from that time zone (* the files are sorted into folders representing time zones A, B, C, D, E)
3. load the file & the program needed to run it (in this case max/msp)
4. choose a random duration, and tell app how long to last
5. close the file & the program needed to run it
6. wait
7. Check the current time
.... continue loop until midnight, then shutdown computer.
(we are running G5 Dual 1.8 1Gb Ram OS X 10.3.8)
We have been carrying out tests with the system and it usually crashes a few days in. The idea is that the computer will be unsupervised and it is currently not stable enough for our project. Does anyone have any advice/suggestions with the applescript or perhaps any other solutions? We also have some problems with the random number generator, it seems to favour some numbers rather than others!
Many thanks,
Christopher McClelland
_____________________
Sonic Arts Research Centre
Queen's University, Belfast
email@hidden<x-tad-bigger>
</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>RVHloc</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> "Macintosh HD:Applications:MaxMSP 4.5:patches:rvh:" -- location of the files...
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>timeinsecs</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>time</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>of</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>current date</x-tad-bigger><x-tad-bigger>))
--</x-tad-bigger>
<x-tad-bigger> time in applescript is the no of seconds since midnight!</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>round</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>timeinsecs</x-tad-bigger><x-tad-bigger> / 3600) </x-tad-bigger>
<x-tad-bigger>rounding</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>down</x-tad-bigger><x-tad-bigger>)
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>fold</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> ""
</x-tad-bigger>
<x-tad-bigger>repeat</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>until</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> < 1 -- so after midnight stops repeat
</x-tad-bigger>
<x-tad-bigger>if</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> ≥ 6 </x-tad-bigger>
<x-tad-bigger>and</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> < 8 </x-tad-bigger>
<x-tad-bigger>then</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>fold</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> "A"
</x-tad-bigger>
<x-tad-bigger>else</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>if</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> ≥ 8 </x-tad-bigger>
<x-tad-bigger>and</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> < 10 </x-tad-bigger>
<x-tad-bigger>or</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> ≥ 12 </x-tad-bigger>
<x-tad-bigger>and</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> < 14 </x-tad-bigger>
<x-tad-bigger>then</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>fold</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> "B"
</x-tad-bigger>
<x-tad-bigger>else</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>if</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> ≥ 10 </x-tad-bigger>
<x-tad-bigger>and</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> < 12 </x-tad-bigger>
<x-tad-bigger>or</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> ≥ 16 </x-tad-bigger>
<x-tad-bigger>and</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> < 19 </x-tad-bigger>
<x-tad-bigger>then</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>fold</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> "C"
</x-tad-bigger>
<x-tad-bigger>else</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>if</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> ≥ 14 </x-tad-bigger>
<x-tad-bigger>and</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> < 16 </x-tad-bigger>
<x-tad-bigger>or</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> ≥ 19 </x-tad-bigger>
<x-tad-bigger>and</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> < 21 </x-tad-bigger>
<x-tad-bigger>then</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>fold</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> "D"
</x-tad-bigger>
<x-tad-bigger>else</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>if</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> ≥ 21 </x-tad-bigger>
<x-tad-bigger>and</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> < 24 </x-tad-bigger>
<x-tad-bigger>then</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>fold</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> "E"
</x-tad-bigger>
<x-tad-bigger>end</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>if</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>fold</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>sourceFolder</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>RVHloc</x-tad-bigger><x-tad-bigger> & </x-tad-bigger>
<x-tad-bigger>fold</x-tad-bigger><x-tad-bigger> & ":"
</x-tad-bigger>
<x-tad-bigger>tell</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>application</x-tad-bigger><x-tad-bigger> "Finder"
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>fileList</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>every</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>file</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>of</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>folder</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>sourceFolder</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>as</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>alias list</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>len</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>count</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>fileList</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>if</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>len</x-tad-bigger><x-tad-bigger> > 1 </x-tad-bigger>
<x-tad-bigger>then</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>fileloc</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>item</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>random number</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>from</x-tad-bigger><x-tad-bigger> 1 </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>len</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>with seed</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>time</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>of</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>current date</x-tad-bigger><x-tad-bigger>))) </x-tad-bigger>
<x-tad-bigger>of</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>fileList</x-tad-bigger><x-tad-bigger>)
</x-tad-bigger>
<x-tad-bigger>open</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>fileloc</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>delay</x-tad-bigger><x-tad-bigger> 30
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>dur</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>read</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>file</x-tad-bigger><x-tad-bigger> "Macintosh HD:Applications:MaxMSP 4.5:patches:rvh:dur.txt") --</x-tad-bigger>
<x-tad-bigger> Text File with duration in secs (Max/MSP needs this)</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>delay</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>dur</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>as</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>integer</x-tad-bigger><x-tad-bigger> --</x-tad-bigger>
<x-tad-bigger> delay the quitting of Max for the duration of the patch </x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>quit</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>application</x-tad-bigger><x-tad-bigger> "MaxMSP 4.5"
</x-tad-bigger>
<x-tad-bigger>delay</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>random number</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>from</x-tad-bigger><x-tad-bigger> 20 </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> 25)
</x-tad-bigger>
<x-tad-bigger>end</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>if</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>end</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>tell</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>timeinsecs</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>time</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>of</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>current date</x-tad-bigger><x-tad-bigger>))
</x-tad-bigger>
<x-tad-bigger>set</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>thehour</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>to</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>round</x-tad-bigger><x-tad-bigger> (</x-tad-bigger>
<x-tad-bigger>timeinsecs</x-tad-bigger><x-tad-bigger> / 3600) </x-tad-bigger>
<x-tad-bigger>rounding</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>down</x-tad-bigger><x-tad-bigger>)
</x-tad-bigger>
<x-tad-bigger>end</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>repeat</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>tell</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>application</x-tad-bigger><x-tad-bigger> "System Events"
</x-tad-bigger>
<x-tad-bigger>shut down</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>end</x-tad-bigger><x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>tell</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden