Het grote Applescripts & OSA topic

Pagina: 1
Acties:
  • 2.658 views sinds 30-01-2008
  • Reageer

Acties:
  • 0 Henk 'm!

  • benoni
  • Registratie: November 2003
  • Niet online
Het Applescripts & OSA topic vs. het NOS handige scripts topic

Dit topic is verwant aan Het grote "handige scripts" topic in de Non-Windows sectie, maar omdat Applescripts daar een beetje een vreemde eend in de bijt zijn (en niet beschikbaar op andere Unix'en) wil ik deze een plek geven in AppleTalk.

Het zou in sommige gevallen een beetje door elkaar kunnen lopen (denk aan Applescripts als wrapper voor een shell script), in die gevallen zou een korte post met een link naar 'de andere kant' een idee kunnen zijn om (het grootste gedeelte van) het script op de juiste plek te hebben staan en toch makkelijk terug te kunnen vinden.

Wat kun je in dit topic kwijt:
  • Uiteraard je handige Applescripts;
  • Aanvullingen en gebruikstips m.b.t. de geplaatste Applescripts of de Applescript taal;
  • Algemene discussie over Applescript / osascript.

    Anders dan bij het grote "handige scripts" topic wil ik hier meer ruimte voor discussie laten, dit omdat het werken met Applescript tot typische 'waarom?' vragen kan leiden. Voor de 'hoe?' vragen kun je beter zelf een topic openen, zodat het aandacht krijgt en efficiënter is terug te vinden.




OSA en osascript

OSA staat voor Open Scripting Architecture (OSA), zoals Apple het omschrijft is het een 'standard and extensible mechanism for interapplication communication in Mac OS X.' Het is de voortzetting van het idee waaruit onder het oude MacOS de AppleEvents technieken en Applescript zijn geboren. De heilige graal [sic] is het 'Open Scripting framework', een scripting API die uiteindelijk scripts minder afhankelijk zou moeten maken van de scriptingtaal. In feite zou je een script met een enkele menukeuze moeten kunnen switchen van een Applescript dialect naar bijvoorbeeld een Javascript dialect, zonder dat de werking verandert. Dat werd in 1993 beoogd door William R. Cook en Warren H. Harris:
More than half of Apple’s market is international, and we felt that it was inappropriate to limit the script-writing populous to only the English-speaking. Dialects were introduced as a way to internationalize AppleScript. A dialect specifies the syntax of AppleScript. The examples in this paper are presented in the English dialect of AppleScript. Other dialects exist for Japanese and French, while others are under development. For example, here are translations of scripts into other dialects:

English:
the first character of every word whose style is bold
French:
le premier caractère de tous les mots dont style est gras
Professional:
{ words | style == bold}.character[1]
Verder heeft Apple technieken in Applescript verwerkt om scripts 'op te nemen', dus de uit te voeren handelingen handmatig voor te doen, en daarmee het script aan te vullen. De Finder bijvoorbeeld biedt deze functionaliteit, het is leuk om snel vertrouwd te raken met Applescript of om te gebruiken voor kleine stukjes scripting, maar veel handiger dan dat is het niet.

De afkorting OSA vind je terug in osascript, een set shell commando's waarmee Applescript naar de command shell wordt gebracht. Misschien dat Apple de merkvrije naam 'osascript' erbij heeft gehaald om technieken te kunnen delen met andere bedrijven of vrij te geven, maar daar heb ik verder geen inzicht in.

Applescript, een zegen en een vloek

Applescript is geroemd, vanwege het doordachte interoperationele object model die een ongeëvenaard directe interface biedt om in actieve gebruikersapplicaties met objecten en opdrachten te kunnen spelen. Sommige ontwikkelaars (o.a. van Indesign, XPress, Microsoft Excel Mac, Filemaker Pro, TextWrangler) hebben Applescript ondersteuning door hun gehele applicatie verwerkt, of gecombineerd met een eigen scripting omgeving. Hierdoor wordt zo'n applicatie heel transparant, vanuit Applescript kun je de objecten in de geopende vensters benaderen en de functies die het programma biedt aanroepen, wat vooral een voordeel biedt in gevallen waar scripting wordt gecombineerd met niet te automatiseren taken. Zoals bij het produceren van een productencatalogus, dat kun je zo scripten dat de vormgever zich helemaal kan concentreren op de indeling. Productafbeeldingen, tekstblokken en tabellen worden door met een druk op de knop in de pagina geplaatst en kunnen door de scripting worden bijgewerkt als er in de database wat wijzigt.

Applescript is ook berucht, vanwege de interpreter die enerzijds veel vrijheden toelaat, maar anderzijds de power user flink dwars kan zitten doordat het geen redelijke alternatieven biedt voor constructies die in vrijwel alle andere programmeertalen gemeengoed zijn. Wat in de praktijk ook een groot probleem kan worden is dat in de verschillende applicaties de objecten anders worden behandeld, wat voor allerlei casting problemen kan zorgen als je objecten van de ene naar de andere applicatie overdraagt. Soms is de 'scriptability' in programma's maar deels doorgevoerd, of zijn de gekoppelde objecten en functies bij een update aangepast, en daardoor werken bepaalde events anders dan aangegeven, of helemaal niet. Over het algemeen werkt Applescript ook vrij traag, vooral omdat programma's na elke stap het beeld bijwerken, maar dat vinden veel gebruikers niet zo'n probleem omdat ze daardoor wel visuele controle hebben op het proces.

Tips:
  • Gebruik de woordenboek functie om alle methoden en objecten te vinden van een programma.
  • In het woordenboek 'StandardAdditions.sdef' staan de algemene methoden en objecten.
  • Je kunt OSAX Scripting Additions toevoegen voor extra functies,

    maar let op de uitwisselbaarheid.
Links:



Om je scripts te posten:

In dank gepikt van pinball het handige sjabloontje voor het presenteren van je geesteskinderen:

[b]Naam: [/b]
[b]Doel: [/b]
[b]Werking: [/b]
[b]Vereiste additions: [/b]
[b]Configuratie: [/b]
[b]Parameters: [/b]
[b]Opmerkingen: [/b]
[code]
[/code]

Acties:
  • 0 Henk 'm!

  • benoni
  • Registratie: November 2003
  • Niet online
Naam: Stuntel
Doel: Snel en simpel een SSH tunneltje openen en inloggen op de server.
Werking: Popt een menu op met voorgeconfigureerde tunneltjes. Hieruit kun je een selectie maken. Stuntel bouwt elke tunnel in een terminalvenster, wacht daarna tot de tunnel open is, en logt aansluitend in op de bijbehorende services voorzover deze in de profielen zijn aangegeven. Voor de lokale poort kan een range worden opgegeven, daarvan wordt dan de eerste beschikbare poort gebruikt. Doordat dit poortnummer wordt meegegeven aan de functie die inlogt op de service, wordt de gebruiker niet belast met aanpassingen van server-adressen op het moment dat er een poort bezet is.
Vereiste additions: Geen.
Configuratie: In het script zelf, volg de aanwijzingen.
Parameters: Geen.
Opmerkingen: SSH geeft bij mij op willekeurige momenten een fout 'administratively prohibited' maar voorzover ik zie ligt dat niet aan het script maar aan een tunnelserver die het soms even niet meer weet.
Tip: Als je bij AFP verbindingen de UsrName en UsrPass invult logt ie op de fileserver in zonder een wachtwoord te vragen :o :)
Voor Citrix kun je configuratie en de hash code voor 't wachtwoord overnemen uit het tekstbestand dat 'Citrix ICA Client editor.app' bewaart. Stuntel maakt zelf een tijdelijke configuratie voor Citrix aan in de /temp map. Het Citrix configuratiebestand is verder niet nodig en kan dus ook niet kwijtraken.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
-- Stuntel
-- 
-- SSH Tunnel Telework script
--
-- Characteristic features:
-- - Stores all configuration profiles within the script
--   (which adds some obscurity if the script is saved as application file)
-- - Tunnel commands are issued using Terminal
-- - Automates workflow using modular functions for attached login procedures
--   (Apple Fileserver, Citrix Presentation Server, VNC, SSHFS)
-- - Stuntel can also open these services without a tunnel
-- 
-- How to configure:
-- - Go to the 'Initialise profiles' section below
-- - Set your basic configuration in the 'presets' directory
--   (the part where you see the comments that explain each setting)
-- - For each service you want to see in the menu, add a profile to the profiles list
--   (which is as simple as copy'n'pasting the sample code and altering the values)
-- 
-- Written by benoni, 30 November 2007
-- Updated: 8 January 2009
-- License: free as in GPL


-- Globals
-- 
property scrName : "Stuntel"
property scrVers : "1.0"


-- Hit & run
--
on run
    
    -- Initialise profiles
    set profiles to getProfiles() of me
    
    -- Read profiles into menu
    set choices to getMenu(profiles) of me
    
    -- Choose a profile
    set results to askUser(choices) of me
    
    -- Match choices
    repeat with n from 1 to (count profiles)
        if ((item n of choices) is in results) then
            
            -- Get profile
            set profile to item n of profiles
            
            -- Open a tunnel if needed
            if ((tunHost of profile) = "") then
                set success to tunNone(profile) of me
            else
                set success to tunOpen(profile) of me
            end if
            
            -- Run attached login procedures
            if (success) then
                if ((tunType of profile) = "login") then
                    if ((dstProt of profile) = "AFP") then tryAFP(profile) of me
                    if ((dstProt of profile) = "ICA") then tryICA(profile) of me
                    if ((dstProt of profile) = "VNC") then tryVNC(profile) of me
                    if ((dstProt of profile) = "SSHFS") then trySSHFS(profile) of me
                end if
                if ((tunType of profile) = "reverse") then
                    if ((dstProt of profile) = "VNC") then tryVNCServer(profile) of me
                end if
            end if
            
        end if
    end repeat
    
end run


-- Initialise profiles
--
on getProfiles()
    set presets to ¬
        {dstHost:"", dstName:"", dstPort:"", dstProt:"", locPort:"", tunHost:"", tunPort:"", tunType:"", tunUser:"", usrDomn:"", usrName:"", usrPass:"", usrPath:"", varHost:"", varPort:"", varTerm:""} ¬
            
    set profiles to {}
    
    -- The menu option identifying the tunnel (descriptive, unique name for display):
    set dstName of presets to "Tunnel Preset"
    
    -- The destination host (IP address or full domain name):
    set dstHost of presets to "fileserver.office"
    
    -- The destination port (for the service at the other end, not the tunnel server):
    set dstPort of presets to "5900"
    
    -- The protocol (for "AFP", "ICA", "VNC" and "SSHFS", login functions are defined):
    set dstProt of presets to "VNC"
    
    -- The local port(s) to use for tunneling (should be above 1024, use "~" to imply a range):
    set locPort of presets to "5899~5000"
    
    -- The tunnel server (IP address or full domain name);
    -- leave as "" if you do not want to tunnel but only use the login functions:
    set tunHost of presets to "tunnelserver.example.com"
    
    -- The SSH port to connect to at the tunnel server
    -- (for port knocking use a sequence like "8822 7722 22", the last port number is for ssh):
    set tunPort of presets to "22"
    
    -- The type of tunnel ("normal" and "login" for -L, "reverse" for -R);
    -- reverse mode is used to receive traffic while hidden behind a firewall:
    set tunType of presets to "login"
    
    -- The user name known by the tunnel server:
    set tunUser of presets to "anyone"
    
    -- The additional directory domain, username, password, servershare or filesystem path:
    set usrDomn of presets to ""
    set usrName of presets to ""
    set usrPass of presets to ""
    set usrPath of presets to ""
    
    -- Example 1: local AFP file share, no tunnel needed, automated cleartext password:
    copy presets to profile
    set dstName of profile to "Local Linux/Netatalk Fileserver"
    set dstHost of profile to "10.0.0.1"
    set dstPort of profile to ""
    set dstProt of profile to "AFP"
    set tunHost of profile to "" -- disable tunnel preset
    set usrName of profile to "myname"
    set usrPass of profile to "secret"
    set usrPath of profile to "Home%20Directory"
    set profiles to profiles & {profile}
    
    -- Example 2: Citrix server at work, accessed through preset SSH tunnel:
    copy presets to profile
    set dstName of profile to "Citrix Server at work"
    set dstHost of profile to "192.168.1.2"
    set dstPort of profile to "1494"
    set dstProt of profile to "ICA"
    set locPort of profile to "1494~" -- try local port 1494 or higher
    set usrDomn of profile to "WORKGROUP"
    set usrName of profile to "myself"
    set usrPass of profile to "000000000000000000000000000000000000"
    set profiles to profiles & {profile}
    
    -- Example 3: Workstation at work, accessed through preset SSH tunnel,
    -- port knocking the tunnel server on 4321 before tunneling through port 22:
    copy presets to profile
    set dstName of profile to "Workstation 11"
    set dstHost of profile to "ws011.admin.wg"
    set dstPort of profile to "5900"
    set dstProt of profile to "VNC"
    set tunHost of profile to "office.example.com"
    set tunPort of profile to "4321 22"
    set usrName of profile to ""
    set profiles to profiles & {profile}
    
    -- Example 4: SSHFS acces to webserver (using MacFuse and /usr/local/bin/sshfs):
    copy presets to profile
    set dstName of profile to "SCP Webserver"
    set dstHost of profile to "webserver.example.com"
    set dstPort of profile to "" -- use standard port
    set dstProt of profile to "SSHFS"
    set tunHost of profile to "" -- tunneling is not needed for the webserver
    set usrName of profile to "admin"
    set profiles to profiles & {profile}

    return profiles
end getProfiles


-- Make menu
--
on getMenu(profiles)
    set choices to {}
    
    repeat with profile in items in profiles
        set choices to choices & {(dstName of profile) & ":" & (dstProt of profile)}
    end repeat
    
    return choices
end getMenu


-- Pick from menu
--
on askUser(choices)
    set winName to scrName
    set message to scrName & " " & scrVers & return & return & "Welcome!" & return & "Choose the service(s) you want to use:"
    
    set results to choose from list choices with title winName with prompt message with multiple selections allowed
    
    return results
end askUser


-- Open a tunnel
--
on tunOpen(profile)
    set winName to (scrName of me) & " - " & (dstName of profile) & ":" & (dstPort of profile)
    
    -- Open new Terminal window
    tell application "Terminal"
        activate
        delay 1
        do script ("# Starting SSH tunnel to " & (dstName of profile) & " for " & (dstProt of profile) & ".")
        set termWin to (a reference to window 1)
        set custom title of termWin to winName
        delay 1
        do script ("# Please wait for the password prompt and follow the instructions.") in termWin
    end tell
    
    -- Port knocking sequence
    set tunPort to (tunPort of profile) as text
    set n to count (words of tunPort)
    if (n > 1) then
        repeat with x in (words 1 through (n - 1) of tunPort)
            set message to "# Port knocking server " & (tunHost of profile) & " port " & x & ":"
            set command to "telnet " & (tunHost of profile) & " " & x
            
            -- Issue port knock command in Terminal window
            tell application "Terminal"
                activate
                do script message in termWin
                do script command in termWin
                delay 1
            end tell
            
        end repeat
        set tunPort to (word n of tunPort)
    end if
    
    -- Get local port number
    set a to (locPort of profile) as text
    set n to offset of "~" in a
    if (n = 0) then
        set portNum to a as integer
        if ((portNum < 1025) or (portNum > 65535)) then
            display dialog "Local port for tunnel should be over 1024 to avoid privileged ports, and under 65536."
            return false
        end if
        if (tunTest(portNum) of me) then
            display dialog "Local port for tunnel is not free."
            return false
        end if
    else
        set portNum to 0
        set portMin to 0
        set portMax to 0
        set l to count (characters of a)
        if (n > 1) then
            set portMin to ((characters 1 through (n - 1) of a) as text) as integer
        end if
        if (n < l) then
            set portMax to ((characters (n + 1) through l of a) as text) as integer
        end if
        if ((portMin < 1025) or (portMin > 65535)) then set portMin to 1025
        if ((portMax < 1025) or (portMax > 65535)) then set portMax to 65535
        if (portMax > portMin) then
            set step to 1
        else
            set step to -1
        end if
        repeat with n from portMin to portMax by step
            if (not (tunTest(n) of me)) then
                set portNum to n
                exit repeat
            end if
        end repeat
        if (portNum = 0) then
            display dialog "Could not find any open ports (tried " & portMin & "~" & portMax & ")."
            return false
        end if
    end if
    
    -- Build tunnel command
    set message to "# To close the tunnel, use ctrl-c, or close the terminal window."
    if ("rev" is in (tunType of profile)) then
        set command to "ssh -R " & (dstPort of profile) & ":" & (dstHost of profile) & ":" & portNum
    else
        set command to "ssh -L " & portNum & ":" & (dstHost of profile) & ":" & (dstPort of profile)
    end if
    set command to command & " -N " & (tunUser of profile) & "@" & (tunHost of profile)
    if (not ((tunPort as integer) = 0)) then set command to command & " -p " & tunPort
    
    -- Issue tunnel command in Terminal window
    tell application "Terminal"
        activate
        do script message in termWin
        do script command in termWin
        delay 1
    end tell
    
    -- Store variables
    set (varHost of profile) to "127.0.0.1"
    set (varPort of profile) to portNum
    set (varTerm of profile) to termWin
    
    -- Wait until tunnel is connected or timeout
    if ("rev" is in (tunType of profile)) then
        set results to true
    else
        set results to false
        repeat with timer from 1 to 60
            delay 1
            if (tunTest(portNum) of me) then
                tell application "Terminal"
                    set miniaturized of termWin to true
                end tell
                set results to true
                exit repeat
            end if
        end repeat
    end if
    
    return results
end tunOpen


-- Don't open a tunnel
--
on tunNone(profile)
    
    -- Store variables
    set (varHost of profile) to (dstHost of profile)
    set (varPort of profile) to (dstPort of profile)
    
    return true
end tunNone


-- Test for local port
--
on tunTest(port)
    set command to "lsof -i tcp@127.0.0.1:" & port & " -l -n | wc -l"
    set results to do shell script command
    
    if (((results as text) as integer) = 0) then return false
    
    return true
end tunTest


-- Try AFP login
--
on tryAFP(profile)
    set dstLink to "afp://" & (usrName of profile) & "@" & (varHost of profile)
    if (not (((varPort of profile) as integer) = 0)) then set dstLink to dstLink & ":" & (varPort of profile)
    if (not (usrPath of profile) = "") then set dstLink to dstLink & "/" & (usrPath of profile)
    
    try
        if ((usrPass of profile) = "") then
            open location dstLink
        else
            mount volume dstLink as user name (usrName of profile) with password (usrPass of profile)
        end if
    on error
        return false
    end try
    
    return true
end tryAFP


-- Try ICA ('Citrix' Xen Presentation Client) login
--
on tryICA(profile)
    set icaPref to {¬
        "[WFClient]", ¬
        "Version=1", ¬
        "", ¬
        "[ApplicationServers]", ¬
        "Connection To Citrix Server=", ¬
        "", ¬
        "[Connection To Citrix Server]", ¬
        "DoNotUseDefaultCSL=On", ¬
        "LocHttpBrowserAddress=" & (varHost of profile) & ":" & (varPort of profile), ¬
        "Domain=" & (usrDomn of profile), ¬
        "Username=" & (usrName of profile), ¬
        "WinStationDriver=ICA 3.0", ¬
        "TransportDriver=TCP/IP", ¬
        "ZLMouseMode=2", ¬
        "ZLKeyboardMode=0", ¬
        "UseDefaultEncryption=On", ¬
        "ProxyUseDefault=On", ¬
        "Compress=On", ¬
        "AudioBandwidthLimit=1", ¬
        "ClientAudio=On", ¬
        "DesiredColor=8", ¬
        "UseFullScreen=No", ¬
        "DesiredVRES=768", ¬
        "DesiredHRES=1024", ¬
        "Password=" & (usrPass of profile), ¬
        "Address=" & (varHost of profile) & ":" & (varPort of profile)}
    
    try
        set tmpName to "Citrix-settings-" & (varPort of profile) & ".txt"
        tell application "Finder"
            -- Save temporary file in /tmp
            set tmpPath to ((name of startup disk) & ":private:tmp:")
            set foldRef to tmpPath as alias
            -- Alternative: save to desktop
            --set foldRef to item "Desktop" of home
            --copy (foldRef as text) to tmpPath
            if (exists (item tmpName of foldRef)) then move (item tmpName of foldRef) to trash
            set fileRef to make new file in foldRef with properties {name:tmpName}
            
            set tmpFile to open for access (tmpPath & tmpName) with write permission
            repeat with a in icaPref
                write a & return to tmpFile
            end repeat
            close access tmpFile
            
            set creator type of fileRef to "IICA"
            set file type of fileRef to "TEXT"
        end tell
        
        open fileRef
    on error
        return false
    end try
    
    return true
end tryICA


-- Try MacFuse SSHFS login
--
on trySSHFS(profile)
    set winName to (scrName of me) & " - " & (dstName of profile) & ":" & (dstProt of profile)
    set message to "# Mounting SSHFS share from " & (dstName of profile)
    
    -- Make new mount in /Volumes
    set mntName to ""
    tell application "Finder"
        set mntPath to ((name of startup disk) & ":Volumes")
        set foldRef to mntPath as alias
        set tryName to (dstName of profile)
        if (exists (item tryName of foldRef)) then
            repeat with n from 1 to 100
                set tryName to (dstName of profile) & "-" & n
                if (not (exists (item tryName of foldRef))) then
                    set mntName to tryName
                    exit repeat
                end if
            end repeat
        else
            set mntName to tryName
        end if
    end tell
    if (mntName = "") then return false
    
    set command to "mkdir /Volumes/\"" & mntName & "\"; "
    set command to command & "/usr/local/bin/sshfs"
    if (not (((varPort of profile) as integer) = 0)) then set command to command & " -p " & (varPort of profile)
    set command to command & " " & (usrName of profile) & "@" & (varHost of profile)
    if (not (usrPath of profile) = "") then set command to command & ":" & (usrPath of profile)
    set command to command & " /Volumes/\"" & mntName & "\""
    
    -- Issue tunnel command in new Terminal window
    tell application "Terminal"
        activate
        do script message in termWin
        do script command in termWin
        set termWin to (a reference to window 1)
        set custom title of termWin to winName
    end tell
    
    return true
end trySSHFS


-- Try VNC login
--
on tryVNC(profile)
    set dstLink to "vnc://" & (usrName of profile) & "@" & (varHost of profile) & ":" & (varPort of profile)
    
    try
        open location dstLink
    on error
        return false
    end try
    
    return true
end tryVNC


-- Try VNC server
--
on tryVNCServer(profile)
    set winName to (scrName of me) & " - " & (dstName of profile) & ":" & (dstPort of profile)
    set message to "# VNC server for login from " & (dstName of profile) & " (afbreken met ctrl-c):"
    
    -- Locate VNC server
    set vncPath to (do shell script "locate -l 1 *OSXvnc.app/OSXvnc*")
    
    if ((count (characters of vncPath)) = 0) then
        
        -- No VNC server found
        return false
    else
        
        -- VNC Server command
        set command to "\"" & vncPath & "\" -alwaysshared -rendezvous none -localhost -rfbport " & (varPort of profile)
        
        -- Issue VNC Server command in new Terminal window
        tell application "Terminal"
            activate
            do script message in termWin
            do script command in termWin
            set termWin to (a reference to window 1)
            set custom title of termWin to winName
            set miniaturized of termWin to true
        end tell
        
        return true
    end if
end tryVNCServer

[ Voor 255% gewijzigd door benoni op 09-01-2009 11:25 ]


  • benoni
  • Registratie: November 2003
  • Niet online
Naam: indBookmarker
Doel: PDFs exporteren met inhoudsopgave in de bookmarks, zonder gebruik van Table of Contents.
Werking: Kijkt alle tekst in het document na op kopregels, maakt hiervoor bookmarks aan
Vereiste additions: Geen
Configuratie: Onder 'Settings' in het script
Parameters: Geen
Opmerkingen:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
-- indBookmarker 0.2.1
-- 
-- Search for title headers in InDesign, turn them into anchors, add them to the bookmarks.
--
-- Much like the TOC function, but the bookmark links are attached to the story text.
-- To be used for PDF exports, eBooks and such, expandable for customized scripted exports.
-- 
-- Written by benoni, 28 Feb 2008
-- License: free as in GPL


-- Please set the paragraph style names according to the document contents hierarchy
-- Then run this script, and export to PDF with bookmarks and hyperlinks

-- Settings
set indexStyles to {"Kop 1", "Kop 2", "Kop 3", "Kop 4"}
set linkNumPrefix to "Link_"

-- Run
tell application "Adobe InDesign CS3"
    
    -- Get levels for hierarchy depth
    set maxLevel to count (items of indexStyles)
    set newLevel to 1
    
    -- Populate bread crumb list
    set parBookmarks to {a reference to document 1} & indexStyles
    
    -- Number the links
    set numLink to 0
    
    -- Get the frontmost document
    tell document 1
        
        -- Rotate through paragraphs in document
        repeat with curStory in stories
            repeat with curParagraph in paragraphs of curStory
                set curTitle to (line 1 of curParagraph) as text
                
                -- Check if the paragraph has text in it
                if ((count (characters of curTitle)) > 1) then
                    
                    -- Get paragraph style
                    set curStyle to (name of applied paragraph style of curParagraph) as text
                    
                    -- Compare with given paragraph styles
                    repeat with curLevel from 1 to maxLevel
                        set indexStyle to (item curLevel of indexStyles) as text
                        
                        -- Check if the paragraph style is intended to have a bookmark
                        if (curStyle = indexStyle) then
                            
                            -- Make a new ID for linked paragraph
                            set numLink to numLink + 1
                            set linkID to linkNumPrefix & (numLink as text)
                            
                            -- Turn paragraph into hyperlink destination
                            set curDestination to make new hyperlink text destination with properties ¬
                                {destination text:curParagraph, hidden:true, name:linkID}
                            
                            -- Fill in the gaps when curLevel has no parent level
                            repeat with addLevel from (newLevel + 1) to curLevel
                                set (item addLevel of parBookmarks) to (item newLevel of parBookmarks)
                            end repeat
                            
                            -- Add the bookmark pointing to the hyperlink destination
                            set curBookmark to make new bookmark at (item curLevel of parBookmarks) with properties ¬
                                {destination:curDestination, indent:curLevel, name:(curTitle as string)}
                            
                            -- Set current item as parent for next level
                            set newLevel to (curLevel + 1)
                            set (item newLevel of parBookmarks) to curBookmark
                            
                            exit repeat
                        end if
                    end repeat
                end if
            end repeat
        end repeat
    end tell
end tell

[ Voor 3% gewijzigd door benoni op 14-03-2008 16:19 ]


  • sOid
  • Registratie: Maart 2004
  • Niet online
Goed initiatief. Ik ben beginnend Mac gebruiker en weet nog niets van die scripts af. Hoop hier wat op te steken maar dat zal vast wel ;)

Wel even een verzoekje. Ik weet niet of 't mogelijk is, maar het zou prettiger zijn als er een extern linkje naar het script komt ipv hier direct te plaatsen. Nogal veel scrollwerk enzo :/

  • breinonline
  • Registratie: Juni 2001
  • Nu online

breinonline

Are you afraid to be known?

sOid schreef op donderdag 28 februari 2008 @ 22:14:
Wel even een verzoekje. Ik weet niet of 't mogelijk is, maar het zou prettiger zijn als er een extern linkje naar het script komt ipv hier direct te plaatsen. Nogal veel scrollwerk enzo :/
Spatiebalk of end-toets?

WP: Mitsubishi Ecodan PUHZ-SHW112YAA, ERSC-VM2C, Procon ┃ PV: 4800Wp, SolarEdge SE5K, 15x JAM60S17/320, ZW 15º ┃ WTW: Zehnder Q600 ┃ SH: Home Assistant, Proxmox, Intel NUC 8i5 Mini


  • sOid
  • Registratie: Maart 2004
  • Niet online
Dan nog. Het houdt het topic wel overzichtelijker om het als externe link te plaatsen (of een maximum grootte te geven aan de boxen dat je gewoon cmd+a doet om alles te selecteren als je het script wilt hebben, maar geen idee of dat mogelijk is).

Acties:
  • 0 Henk 'm!

  • whitehouse
  • Registratie: Maart 2000
  • Laatst online: 18-09-2019
ik ga zelf ook wat inlezen in AppleScript.
Ik wil, dat als ik een email met het onderwerp 'ToDo' naar mijn email adres stuur, dat als hij binnenkomt in Mail.app, er automatisch een ToDo wordt aangemaakt.

leuke uitdaging ;)

| www.everythingisspiritual.com | www.mosaic.org |


Acties:
  • 0 Henk 'm!

  • daniëlpunt
  • Registratie: Maart 2004
  • Niet online

daniëlpunt

monkey's gone to heaven

Handig topic. :)

Ik had een aantal handige scripts, maar die ben ik kwijt geraakt. Applescript is erg handig en krachtig. :) Maar voor sommige taken is Automator beter geschikt.

Acties:
  • 0 Henk 'm!

  • benoni
  • Registratie: November 2003
  • Niet online
Naam: Nachtvorstmelder
Doel: Mensen werkzaam op een fruitteeltbedrijf waarschuwen bij nachtvorst
Werking: Leest temperatuur hardop voor van knmi.nl als deze onder een minimum komt
Vereiste additions: Geen
Configuratie: In het script, met dialoogvensters
Parameters: Geen
Opmerkingen: Let op met laptop batterijen en energiestand instellingen, spreek altijd met iemand af om elkaar te waarschuwen, voor alle zekerheid :)
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
-- Frost Alarm
--
-- Checks weather report web site for given temperature
-- Alarms when temperature reaches minimum level
--
-- Written: benoni, 8 April 2008
-- License: free as in GPL


-- Gebruiksaanwijzing:
-- - Open Scripteditor (in Hulpprogramma's);
-- - Kopieer dit gehele script en plak deze in het venster;
-- - Bewaar het als programma met de naam 'Nachtvorstmelder',
--   met de optie 'Niet Sluiten' aan, 'Openingsvenster' uit.


-- Presets
property scrName : "Nachtvorstmelder"
property scrVers : "0.9"
property metList : {¬
    "KNMI - Terschelling", ¬
    "KNMI - Den Helder", ¬
    "KNMI - Schiphol", ¬
    "KNMI - Rotterdam", ¬
    "KNMI - Vlissingen", ¬
    "KNMI - Leeuwarden", ¬
    "KNMI - Eelde", ¬
    "KNMI - Twenthe", ¬
    "KNMI - Lelystad", ¬
    "KNMI - De Bilt", ¬
    "KNMI - Eindhoven", ¬
    "KNMI - Maastricht", ¬
    "Meteo24 - Geldermalsen", ¬
    "hetweeractueel.nl gelderland - aalten", ¬
    "hetweeractueel.nl gelderland - borculo", ¬
    "hetweeractueel.nl gelderland - boven-leeuwen", ¬
    "hetweeractueel.nl gelderland - culemborg", ¬
    "hetweeractueel.nl gelderland - dieren", ¬
    "hetweeractueel.nl gelderland - doetinchem", ¬
    "hetweeractueel.nl gelderland - doetinchem-dichteren", ¬
    "hetweeractueel.nl gelderland - doetinchem-vijverberg", ¬
    "hetweeractueel.nl gelderland - doornenburg", ¬
    "hetweeractueel.nl gelderland - epe", ¬
    "hetweeractueel.nl gelderland - geldermalsen-elzenbos", ¬
    "hetweeractueel.nl gelderland - groenlo", ¬
    "hetweeractueel.nl gelderland - hattemerbroek", ¬
    "hetweeractueel.nl gelderland - heerde", ¬
    "hetweeractueel.nl gelderland - hengelo-gld", ¬
    "hetweeractueel.nl gelderland - huissen", ¬
    "hetweeractueel.nl gelderland - kapel-avezaath", ¬
    "hetweeractueel.nl gelderland - kerkdriel", ¬
    "hetweeractueel.nl gelderland - maurik-betuwe", ¬
    "hetweeractueel.nl gelderland - maurik-buren", ¬
    "hetweeractueel.nl gelderland - meddo", ¬
    "hetweeractueel.nl gelderland - millingen", ¬
    "hetweeractueel.nl gelderland - nijmegen", ¬
    "hetweeractueel.nl gelderland - oldebroek", ¬
    "hetweeractueel.nl gelderland - ruurlo", ¬
    "hetweeractueel.nl gelderland - silvolde", ¬
    "hetweeractueel.nl gelderland - stokkum", ¬
    "hetweeractueel.nl gelderland - vaassen", ¬
    "hetweeractueel.nl gelderland - varsseveld", ¬
    "hetweeractueel.nl gelderland - vierhouten", ¬
    "hetweeractueel.nl gelderland - vragender", ¬
    "hetweeractueel.nl gelderland - waardenburg", ¬
    "hetweeractueel.nl gelderland - wageningen", ¬
    "hetweeractueel.nl gelderland - well", ¬
    "hetweeractueel.nl gelderland - wijchen", ¬
    "hetweeractueel.nl gelderland - winterswijk-henxel", ¬
    "hetweeractueel.nl gelderland - zaltbommel"}
property presets : {setMeteoStation:"hetweeractueel.nl gelderland - maurik-betuwe", setCheckSeconds:600, setAlarmSeconds:60, setCriticalTemp:-1}
property failing : false
property running : false


-- Start here
on run
    
    -- First set switch to non-idle mode
    set running to false
    
    -- Ask to change presets, or default to idle ('daemon') mode 
    set msg to "Welkom bij het " & scrName & " script." & return
    set msg to msg & return
    set msg to msg & "De huidige instellingen zijn:" & return
    set msg to msg & "minimaal " & (setCriticalTemp of presets) & " graden Celcius"
    set msg to msg & " in " & (setMeteoStation of presets) & "." & return
    set msg to msg & return
    set msg to msg & "Dit meldingsvenster sluit vanzelf." & return
    activate
    display dialog msg with title scrName buttons {"Aanpassen", "Stop", "OK"} ¬
        default button 3 giving up after 10
    set answer to button returned of result
    
    if (answer is "Stop") then return
    
    if (answer is "Aanpassen") then
        
        -- Set frost alarm temperature
        display dialog "Kritische temperatuur (graden Celsius):" with title scrName ¬
            default answer setCriticalTemp of presets
        set setCriticalTemp of presets to text returned of result
        
        -- Choose meteo station
        choose from list metList with title scrName with prompt ¬
            "Kies meteorologisch meetstation:" default items {setMeteoStation of presets} ¬
            without empty selection allowed
        set answer to result
        if (answer is false) then return
        set setMeteoStation of presets to (answer as text)
        
    end if
    
    -- Test reading
    set report to checkTemp() of me
    
    if (flag of report is "fail") then
        
        -- Report error
        set msg to "Er is een fout geconstateerd met het uitlezen" & return
        set msg to msg & "van de temperatuur van de website:" & return & return
        set msg to msg & (info of report)
        activate
        say "Warning"
        display dialog msg with title scrName buttons {"Stop"} default button 1
        
    else
        
        say info of report
        
        -- Now we're ready for idle mode
        set running to true
        
        -- Famous last words
        say "Frost alarm script activated."
        
        -- And some text
        set msg to "Het script checkt " & (setMeteoStation of presets) & " elke "
        set msg to msg & (round ((setCheckSeconds of presets) / 60)) as text
        set msg to msg & " minuten." & return
        set msg to msg & "U hoort daarbij de temperatuur." & return
        set msg to msg & "Onder de kritische grens gaat het geluid hard," & return
        set msg to msg & "en maakt het script elke " & ((setAlarmSeconds of presets) as text)
        set msg to msg & " seconden melding." & return
        set msg to msg & return
        set msg to msg & "De website geeft nu " & temp of report & " graden Celsius op." & return
        set msg to msg & return
        set msg to msg & "Check zelf de volgende punten:" & return
        set msg to msg & "1." & tab & "In Energiestand van Systeemvoorkeuren" & return
        set msg to msg & tab & "moet de bovenste schuif naar rechts" & return
        set msg to msg & tab & "(sluimerstand 'Nooit')." & return
        set msg to msg & "2." & tab & "Vertrouw niet alleen op dit script," & return
        set msg to msg & tab & "gebruik redundante meldsystemen." & return
        set msg to msg & return
        set msg to msg & "Dit meldingsvenster sluit vanzelf." & return
        activate
        display dialog msg with title scrName buttons {"Check Energiestand", "OK"} default button 2 giving up after 30
        
        set answer to button returned of result
        
        if (answer is "Check Energiestand") then
            tell application "System Preferences"
                reveal anchor 3 of pane id "com.apple.preference.energysaver"
            end tell
        end if
        
    end if
    
end run


-- In idle mode, perform checks until user quits
on idle
    if (running) then
        
        -- We are running in background mode
        set report to checkTemp() of me
        if (flag of report is "safe") then
            
            -- Reset failures, tell temperature
            set failing to false
            say (temp of report)
            
        end if
        if (flag of report is "fail") then
            
            -- Report error, escalate to warning if failed before
            if (failing) then
                set flag of report to "warn"
            else
                set failing to true
                say (info of report)
            end if
            
        end if
        if (flag of report is "warn") then
            
            -- Shout warning
            set vol to (get volume settings)
            set volMuting to output muted of vol
            set volOutput to output volume of vol
            set volume without output muted
            set volume output volume 100
            say (info of report)
            set volume output volume volOutput
            set volume output muted volMuting
            
            set msg to "Rapport van " & (city of report) & ":" & return
            set msg to msg & return
            if (failing) then
                set msg to msg & (info of report)
            else
                set msg to msg & "De temperatuur is " & (temp of report) & " graden."
            end if
            activate
            display dialog msg with title scrName buttons {"OK"} default button 1 giving up after 5
            
        end if
        copy report to history
        return (wait of report)
        
    else
        
        -- Not in idle mode, call quit handler
        quit of me
        
    end if
end idle


-- When user hits cmd-Q, or cancels while not in idle mode
on quit
    continue quit
end quit


-- Check and report temperature
on checkTemp()
    set report to ¬
        {city:(setMeteoStation of presets), flag:"fail", info:"Unknown status", temp:"", wait:(setAlarmSeconds of presets)}
    
    try
        if ((city of report) = "Meteo24 - Geldermalsen") then
            set temp of report to fetchTempGeldermalsen() of me
        else
            if ("KNMI" is in (city of report)) then
                set temp of report to fetchTempKNMI(city of report) of me
            else
                set temp of report to fetchTemp(city of report) of me
            end if
        end if
        set test to (first character of (temp of report))
        if (test is in "-0123456789") then
            set info of report to "The temperature now is " & temp of report & " degrees Celsius."
            set val to localNumVal(temp of report)
            set min to localNumVal(setCriticalTemp of presets)
            if (val > min) then
                set flag of report to "safe"
                set wait of report to setCheckSeconds of presets
            else
                set flag of report to "warn"
                set info of report to "Frost warning! " & info of report
            end if
        else
            set info of report to "Problem! The temperature as parsed from the web site looks incorrect."
        end if
    on error errMsg
        set info of report to "Problem! The script encountered an error reading the temperature from the web site."
    end try
    return report
end checkTemp


-- Adapt calculation value to localised setting
on localNumVal(val)
    if ("," is in ((1 / 2) as text)) then
        set cmd to "echo '" & (val as text) & "' | sed 's/\\./,/'"
        set val to do shell script cmd
    end if
    return (val as number)
end localNumVal


-- Fetch temperature from web site
-- (tested KNMI, 08 April 2008)
on fetchTempKNMI(city)
    set cmd to "curl -s http://www.knmi.nl/actueel/index.html | grep -A 2 '"
    set cmd to cmd & (last word of city)
    set cmd to cmd & "' | tail -n 1 | sed 's/^.*>\\([-0-9.]*\\)\\&nbsp;<.*$/\\1/'"
    set val to do shell script cmd
    return (val as text)
end fetchTempKNMI


-- Fetch temperature from web site
-- (tested Meteo24, 09 April 2008)
on fetchTempGeldermalsen()
    set link to "http://www.meteo24.nl/nl/index.php?sid=47617f3ec1d060a&wmoid=31X3122&cityname=Geldermalsen&lat=51.883&lon=5.3&q=detailsite&vis=overview"
    set cmd to "curl -s '" & link & "' | grep -A 1 'temperatuur</strong>&nbsp;'"
    set cmd to cmd & " | tail -n 1 | sed 's/^.*>\\([-0-9.]*\\)<\\/td>.*$/\\1/'"
    set val to do shell script cmd
    return (val as text)
end fetchTempGeldermalsen


-- Fetch temperature from web site
-- (tested www.hetweeractueel.nl, 9 April 2010)
on fetchTemp(city)
    set link to "http://www.hetweeractueel.nl/" & (word 2 of city) & "?hideoffline=yes"
    set cmd to "curl -s '" & link & "' |  grep -A 1 '" & (last word of city) & "' | tail -n 1"
    set cmd to cmd & " | sed 's/^[^<]*<td>\\([-0-9.]*\\).*$/\\1/'"
    set val to do shell script cmd
    return (val as text)
end fetchTemp

[ Voor 45% gewijzigd door benoni op 10-04-2010 13:32 ]


Acties:
  • 0 Henk 'm!

  • sOid
  • Registratie: Maart 2004
  • Niet online
Ik heb even een verzoekje. Ik snap zelf de ballen van AppleScript en heb ook geen tijd om me er in te verdiepen. Ik denk dat het een heel makkelijk scriptje is om te maken voor mensen die het wel kunnen dus stiekem toch een scriptrequest.

Ik zou graag een scriptje hebben die een aantal programma's voor mij opstart met één muisklik. Als ik de mac aanzet heb ik meestal een paar standaard programma's die ik opstart (Adium, Opera, RSS reader, Mail, Calendar) maar niet altijd: alleen als ik op netstroom werk. Is er een scriptje te maken die deze programma's voor mij opstart?

Acties:
  • 0 Henk 'm!

  • chem
  • Registratie: Oktober 2000
  • Laatst online: 04-06 13:08

chem

Reist de wereld rond

als je ze niet nodig hebt, inloggen met shift ingedrukt?

Klaar voor een nieuwe uitdaging.


Acties:
  • 0 Henk 'm!

Anoniem: 140651

sOid schreef op maandag 14 april 2008 @ 22:57:
Ik heb even een verzoekje. Ik snap zelf de ballen van AppleScript en heb ook geen tijd om me er in te verdiepen. Ik denk dat het een heel makkelijk scriptje is om te maken voor mensen die het wel kunnen dus stiekem toch een scriptrequest.

Ik zou graag een scriptje hebben die een aantal programma's voor mij opstart met één muisklik. Als ik de mac aanzet heb ik meestal een paar standaard programma's die ik opstart (Adium, Opera, RSS reader, Mail, Calendar) maar niet altijd: alleen als ik op netstroom werk. Is er een scriptje te maken die deze programma's voor mij opstart?
maar waarom zet je je mac niet in sluimer voortaan ? dan heb je gewoon alles weer als je hem uit sluimer haalt. en daarnaast waarom heb je het alleen nodig als je op netstroom werkt :p ? zoveel stroom gebruiken die progs niet hoor :+

Acties:
  • 0 Henk 'm!

  • benoni
  • Registratie: November 2003
  • Niet online
sOid schreef op maandag 14 april 2008 @ 22:57:
Als ik de mac aanzet heb ik meestal een paar standaard programma's die ik opstart (Adium...
Die Adium widgets zit ook Applescript in, ik heb net bij adiumxtras.com op 'battery' gezocht en vond daar een bruikbaar stukje script voor de batterij status. Klein beetje bewerkt ziet dat er zo uit:

code:
1
2
3
4
5
6
7
8
9
10
-- Open bestanden uit een map aan de hand van batterijstatus
set val to (do shell script "pmset -g ps") as string
if ("AC Power" is in val) then
    set folderName to "Netstroom"
else
    set folderName to "Batterij"
end if
tell application "Finder"
    open items of folder folderName of folder "Startup Items" of folder "Library" of home
end tell


Als je nu een map 'Startup Items' in de bibliotheekmap van je thuismap maakt, daarin maak je mapjes 'Netstroom' en 'Batterij', en in die mapjes sleep je aliassen van je programma's, dan zou 't moeten werken. Het scriptje kun je bewaren met de optie 'Programma', zonder openingsvenster, en dan in je Systeemvoorkeuren -> Accounts -> Inloggen invoegen voor een automatische start :)

Acties:
  • 0 Henk 'm!

  • sOid
  • Registratie: Maart 2004
  • Niet online
Top, bedankt heren. Ik ga het morgen proberen! :)

De reden dat ik het ook handig vind, naast netstroom, is dat als ik mijn Macbook elke nacht op Sluimer zet, hij er nog wel eens automatisch uit komt als ik programma's open laat staan.
Hoe het komt weet ik niet maar ik vermoed dat het een bug is in Leopard. Ik klik dus elke ochtend weer het hele riedeltje programma's aan.

Het is geen ramp maar het kan handiger :)

Van die shifttoets indrukken kende ik niet, ga ik ook eens proberen!

edit: nee ik heb die apps niet alleen nodig als ik op netstroom werk, maar als ik op school even snel wat moet opstarten duurt het toch wat langer dan als ik alleen het juiste programma opstart :)

[ Voor 16% gewijzigd door sOid op 15-04-2008 16:51 ]


Acties:
  • 0 Henk 'm!

  • sOid
  • Registratie: Maart 2004
  • Niet online
Zojuist pas tijd gehad, maar het werkt prima! In ieder geval start hij de juiste programma's op wanneer ik 'm op netstroom heb.

Accu moet ik zo nog even proberen.

Nogmaals bedankt :)

edit: accu doet ie ook goed :)

[ Voor 8% gewijzigd door sOid op 18-04-2008 17:50 ]


Acties:
  • 0 Henk 'm!

  • benoni
  • Registratie: November 2003
  • Niet online
Naam: Rebounds.app
Doel: tec in "Leopard venster positie"
Werking: Zet de afmetingen van het hoofdvenster van een bepaald programma telkens terug op een ingestelde waarde, op het moment dat het programma in de achtergrond wordt gezet (geen focus op het venster).
Vereiste additions: Geen (wel System Events, maar da's standaard)
Configuratie: In het script
Parameters: In het script
Opmerkingen: Het script start het programma ook meteen op. Bewaar het script vanuit Scripteditor als een programma met opties 'zonder openingsvenster', 'niet sluiten'.

AppleScript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
property appName : "Adium"
property winBounds : {10, 20, 800, 400}
property idleTimer : 1 -- 1 second

on run
    tell application appName
        activate
    end tell
    delay 10 -- 10 seconds to give program time to start
    idle of me
end run

on idle
    tell application "System Events"
        set appOpen to count (application processes where name is appName)
    end tell
    if (appOpen > 0) then
        if (frontmost of application appName is false) then
            if (exists (window 1 of application appName)) then
                if ((bounds of window 1 of application appName) is not winBounds) then
                    set bounds of window 1 of application appName to winBounds
                end if
            end if
        end if
    else
        quit of me
    end if
    return idleTimer
end idle

on quit
    continue quit
end quit

Acties:
  • 0 Henk 'm!

  • benoni
  • Registratie: November 2003
  • Niet online
Naam: appWrapper (geef het zelf een naam die lijkt op het programma dat je wilt wrappen)
Doel: Voorbeeldgeval: stop Time Machine service en start vervolgens het programma op, start Time Machine weer als het betreffende programma is afgesloten.
Werking: Zie uitleg in script
Vereiste additions: System Events (standaard)
Configuratie: In het script
Parameters: In het script
Opmerkingen: Bewaar als een programma met opties 'zonder openingsvenster', 'niet sluiten'.
Niet alles is getest, zie verder het rapport dat breinonline hieronder gaat posten :)
Waarschijnlijk is een admin account vereist i.v.m. schrijfactie op TimeMachine prefs.

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
-- appWrapper
--
-- This script shuts off a service (i.e. Time Machine) before opening an application (Lightroom).
-- It waits until the wrapped program has quit and then puts the service back on.
--
-- Save this script as an application using options: 'without opening dialog', 'do not quit'.
-- Copy & paste the application icon of the wrapped program over the script's icon (in the info views).
-- Put this script's icon in the dock instead of the wrapped application.
--
-- Written by: benoni
-- License: free as in GPL

-- Here you should put the name of the wrapped program and the terminal commands to run on open & close.
property myAppName : "Adobe Lightroom"
property onAppOpen : "defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup 0"
property onAppQuit : "defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup 1"
property openTimer : 10 -- seconds to give application time to start
property idleTimer : 10 -- seconds between cycles to check if application is still running

-- In case this scipt is started without dragdrop event,
-- issue the onAppOpen shell script and start the wrapped application
-- (or just put focus to the wrapped application if it was started before).
on run
    do shell script onAppOpen
    tell application myAppName
        activate
    end tell
    delay openTimer
    idle of me
end run

-- In case items are dragged to this script, hand these over to the wrapped application.
on open x
    do shell script onAppOpen
    tell application myAppName
        open x
    end tell
    delay openTimer
    idle of me
end open

-- Watch the wrapped application while running.
-- If the application disappears from the process list, call the quit handler.
on idle
    tell application "System Events"
        set appOpen to count (application processes where name is myAppName)
    end tell
    if (appOpen = 0) then
        quit of me
    end if
    return idleTimer
end idle

-- Quit handler:
-- Issue the onAppQuit shell script and quit this wrapper script.
on quit
    do shell script onAppQuit
    continue quit
end quit

Acties:
  • 0 Henk 'm!

  • breinonline
  • Registratie: Juni 2001
  • Nu online

breinonline

Are you afraid to be known?

Allereerst hartelijk dank voor de hulp benoni!

Het werkt nog niet helemaal zoals het moet: ik heb inderdaad admin rechten nodig en heb daarom bij alle regels met do shell script de tekst with administrator privileges achtergevoegd. Hierdoor krijg ik eerst een venster met de vraag usernaam en wachtwoord in te toetsen alvorens TM wordt uitgeschakeld en Lightroom gestart. Tot zover werkt het prima. Als ik Lightroom sluit, dan blijft TM echter uitstaan (en het script blijft draaien) sluit met wat vertraging.

[ Voor 3% gewijzigd door breinonline op 16-11-2008 16:35 ]

WP: Mitsubishi Ecodan PUHZ-SHW112YAA, ERSC-VM2C, Procon ┃ PV: 4800Wp, SolarEdge SE5K, 15x JAM60S17/320, ZW 15º ┃ WTW: Zehnder Q600 ┃ SH: Home Assistant, Proxmox, Intel NUC 8i5 Mini


Acties:
  • 0 Henk 'm!

  • benoni
  • Registratie: November 2003
  • Niet online
breinonline schreef op zondag 16 november 2008 @ 16:32:
Het werkt nog niet helemaal zoals het moet: ik heb inderdaad admin rechten nodig en heb daarom bij alle regels met do shell script de tekst with administrator privileges achtergevoegd. Hierdoor krijg ik eerst een venster met de vraag usernaam en wachtwoord in te toetsen alvorens TM wordt uitgeschakeld en Lightroom gestart. Tot zover werkt het prima. Als ik Lightroom sluit, dan blijft TM echter uitstaan (en het script blijft draaien) sluit met wat vertraging.
De maximale tijdspanne kun je instellen met de property idleTimer in het script.

Als bij een with administrator privileges commando het script in de achtergrond draait kan het misschien dat je de prompt te laat krijgt of zo. Je kunt er eventueel in een regel ervoor het activate commando plaatsen om de focus te krijgen voor het draaiende script.

Mmm... maar zo te zien zou je het script natuurlijk het liefste standaard met admin-privileges willen starten. Ik denk dat het dan het beste is om het helemaal onafhankelijk van de gebruikers-account als een daemon te laten draaien. Het zou dan herschreven moeten worden als een gewoon shell script (althans, dat verwacht ik omdat het als start op het moment dat er nog geen gebruikersaccount openstaat). Je kunt een launchd plist-bestand aanmaken die het starten en stoppen van het script regelt bij het aan- en uitzetten van de computer. Je zou ook de bestaande launchd config voor backupd (de TimeMachine daemon) kunnen aanpassen, maar dan heb je kans dat dat met een update van het systeem wordt overschreven.

Of er moet toch een mogelijkheid zijn om backupd te laten suspenden als gewone gebruiker... maar zover ik weet is dat een admin privilege :>

[ Voor 37% gewijzigd door benoni op 16-11-2008 17:27 ]


Acties:
  • 0 Henk 'm!

  • breinonline
  • Registratie: Juni 2001
  • Nu online

breinonline

Are you afraid to be known?

Ik heb nu in ~/Library/LaunchAgents de volgende plist aangemaakt:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.apple.TM_temp_disable</string>
    <key>Program</key>
    <string>/Library/LaunchAgents/TM.scpt</string>
    <key>ProgramArguments</key>
    <array>
        <string>/users/reinier/Library/LaunchAgents/TM.scpt</string>
    </array>
    <key>ServiceDescription</key>
    <string>Switches off TimeMachine as long as Lightroom 2 runs</string>
</dict>
</plist>

TM.scrpt ziet er nu zo uit:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- appWrapper
--
-- This script shuts off a service (i.e. Time Machine) before opening an application (Lightroom 2).
-- It waits until the wrapped program has quit and then puts the service back on.
--
-- Save this script as an application using options: 'without opening dialog', 'do not quit'.
-- Copy & paste the application icon of the wrapped program over the script's icon (in the info views).
-- Put this script's icon in the dock instead of the wrapped application.
--
-- Written by: benoni
-- License: free as in GPL

-- Here you should put the name of the wrapped program and the terminal commands to run on open & close.
property myAppName : "Adobe Lightroom 2"
property onAppOpen : "defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup 0"
property onAppQuit : "defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup 1"
property openTimer : 10 -- seconds to give application time to start
property idleTimer : 10 -- seconds between cycles to check if application is still running

-- Watch the wrapped application while running.
-- If the application disappears from the process list, call the quit handler.
on idle
    tell application "System Events"
        set appOpen to count (application processes where name is myAppName)
    end tell
    if (appOpen = 0) then
        quit of me
    end if
    return idleTimer
end idle

-- Quit handler:
-- Issue the onAppQuit shell script and quit this wrapper script.
on quit
    do shell script onAppQuit
    continue quit
end quit

Het oorspronkelijke eerste gedeelte is volgens mij niet meer nodig. TM draait standaard, dus het script moet alleen in de gaten houden dat LR2 opent en dan tijdelijk TM uitschakelen. Als ik herstart dan werkt het echter nog niet. De console geeft dit aan:
code:
1
2
3
4
5
6
7
8
9
10
11
12
16/11/08 17:42:07 com.apple.launchctl.Background[79] launchctl: propertyList is NULL 
16/11/08 17:42:07 com.apple.launchctl.Background[79] launchctl: no plist was returned for: /Library/LaunchAgents/TM.scpt 
16/11/08 17:42:07 com.apple.launchctl.Background[79] launchctl: no plist was returned for: /Library/LaunchAgents/TM.scpt 
16/11/08 17:42:12 com.apple.launchctl.LoginWindow[84] launchctl: Dubious ownership on file (skipping): /Library/LaunchAgents/TM.scpt 
16/11/08 17:42:12 com.apple.launchctl.LoginWindow[84] launchctl: Dubious ownership on file (skipping): /Library/LaunchAgents/TM_temp_disable.plist 
16/11/08 17:42:12 com.apple.launchctl.Background[85] launchctl: Dubious ownership on file (skipping): /Library/LaunchAgents/TM.scpt 
16/11/08 17:42:12 com.apple.launchctl.Background[85] launchctl: Dubious ownership on file (skipping): /Library/LaunchAgents/TM_temp_disable.plist 
16/11/08 17:42:36 com.apple.launchd[1] (com.apple.UserEventAgent-LoginWindow[88]) Exited: Terminated 
16/11/08 17:42:36 com.apple.launchctl.Aqua[100] launchctl: propertyList is NULL 
16/11/08 17:42:36 com.apple.launchctl.Aqua[100] launchctl: no plist was returned for: /Library/LaunchAgents/TM.scpt 
16/11/08 17:42:36 com.apple.launchctl.Aqua[100] launchctl: no plist was returned for: /Library/LaunchAgents/TM.scpt 
16/11/08 17:42:36 com.apple.launchd[77] (com.apple.TM_temp_disable) Unknown key: ServiceDescription

Blijkbaar is er nu iets met de permissies mis?

WP: Mitsubishi Ecodan PUHZ-SHW112YAA, ERSC-VM2C, Procon ┃ PV: 4800Wp, SolarEdge SE5K, 15x JAM60S17/320, ZW 15º ┃ WTW: Zehnder Q600 ┃ SH: Home Assistant, Proxmox, Intel NUC 8i5 Mini


Acties:
  • 0 Henk 'm!

  • benoni
  • Registratie: November 2003
  • Niet online
Hij zegt 'Dubious ownership on file' dus je moet de file chown'en naar root of een andere systeemaccount. Kijk 't even af bij de andere plist-bestanden die in dezelfde map staan.

Verder mag je geen Applescript starten op het moment dat er geen gebruikersomgeving is geopend, en het script werkt nu als daemon niet helemaal goed (het moet immers ook open blijven staan als het programma afsluit, voor 't geval dat je het weer opstart).

Om 't als daemon lekker te laten draaien is i.m.h.o. een shell script het beste om mee te werken. Een cronjob met een shellscript wrapper zou wel kunnen.

Waar ik ook nog aan zat te denken: er zijn ook nog wel andere mogelijkheden om het als Applescript wrapper te laten functioneren denk ik. Time Machine moet de backup disk aangekoppeld zien en daarop een bepaald bestandje kunnen vinden, met een naam als '.time_machine_enabled' of iets dergelijks. In plaats van dat je backupd probeert af te sluiten zou je vanuit het script bijvoorbeeld ook de schijf kunnen ontkoppelen, of het bestandje tijdelijk kunnen hernoemen, in de hoop dat backupd dan meteen in idle modus gaat.

Acties:
  • 0 Henk 'm!

  • breinonline
  • Registratie: Juni 2001
  • Nu online

breinonline

Are you afraid to be known?

Dank voor de heldere uitleg. Er staan nog twee plist-bestanden in mijn LaunchAgents map, die hebben dezelfde permissies. Shell scripts heb ik totaal geen ervaring mee. Ik zal eens googlen hoe dat moet :)

WP: Mitsubishi Ecodan PUHZ-SHW112YAA, ERSC-VM2C, Procon ┃ PV: 4800Wp, SolarEdge SE5K, 15x JAM60S17/320, ZW 15º ┃ WTW: Zehnder Q600 ┃ SH: Home Assistant, Proxmox, Intel NUC 8i5 Mini


Acties:
  • 0 Henk 'm!

  • benoni
  • Registratie: November 2003
  • Niet online
Naast de .plist bestanden zou het script zelf ook admin permissies moeten hebben :)

Maar het hoeft niet als daemon, want je kunt de server share laten ontkoppelen en aankoppelen, dan wordt het zoiets:

AppleScript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
-- appWrapper
--
-- Save this script as an application using options: 'without opening dialog', 'do not quit'.
-- Copy & paste the application icon of the wrapped program over the script's icon (in the info views).
-- Put this script's icon in the dock instead of the wrapped application.
--
-- Written by: benoni
-- License: free as in GPL

-- Here you should put the name of the wrapped program and server share info.
property myAppName : "Adobe Lightroom 2"
property shareName : "TimeMachine"
property shareAddres : "timemachine.local"
property loginName : "breinonline"
property loginPass : "3kraaien"
property openTimer : 10 -- seconds to give application time to start
property idleTimer : 10 -- seconds between cycles to check if application is still running
property quitTimer : 2 -- extra time to wait after wrapped application has shut down

-- In case this scipt is started without dragdrop event,
-- issue the onAppOpen shell script and start the wrapped application
-- (or just put focus to the wrapped application if it was started before).
on run
    thinkOfThisWhenAppOpens() of me
    tell application myAppName
        activate
    end tell
    delay openTimer
    idle of me
end run

-- In case items are dragged to this script, hand these over to the wrapped application.
on open x
    thinkOfThisWhenAppOpens() of me
    tell application myAppName
        open x
    end tell
    delay openTimer
    idle of me
end open

-- Watch the wrapped application while running.
-- If the application disappears from the process list, call the quit handler.
on idle
    tell application "System Events"
        set appOpen to count (application processes where name is myAppName)
    end tell
    if (appOpen = 0) then
        delay quitTimer
        thinkOfThisWhenAppQuits() of me
        quit of me
    end if
    return idleTimer
end idle

-- Quit handler
on quit
    continue quit
end quit

-- Things to do when application opens
on thinkOfThisWhenAppOpens()
    tell application "Finder"
        eject disk shareName
    end tell
end thinkOfThisWhenAppOpens

-- Things to do when application has quit
on thinkOfThisWhenAppQuits()
    mount volume shareName on server shareAddres as user name loginName with password loginPass
end thinkOfThisWhenAppQuits


Let er even op dat ik de acties bij het afsluiten van Lightroom (het opnieuw mounten van de schijf) nu heb verplaatst naar binnenin de idle handler. Dit zou moeten betekenen (ik heb het niet getest) dat als je het script zelf handmatig stopt (cmd-Q) in plaats van Lightroom, dat dan de servershare niet opnieuw wordt gemount. Dat heb ik expres gedaan omdat als je de computer afsluit, beide programma's (het script en Lightroom) tegelijk een quit event krijgen, en dan zou het vervelend zijn als het script daardoor nog even gaat proberen om de servershare te mounten.

Acties:
  • 0 Henk 'm!

  • breinonline
  • Registratie: Juni 2001
  • Nu online

breinonline

Are you afraid to be known?

Als mijn WD My Book disconnected raakt van OS X dan gaat hij automatisch in slaapstand. Helaas lukt het daardoor niet om hem automatisch weer te connecten :/ Volgens mij doet dit script verder precies wat het moet doen. Misschien heeft iemand anders er iets aan. Ik geef het nu even op...

WP: Mitsubishi Ecodan PUHZ-SHW112YAA, ERSC-VM2C, Procon ┃ PV: 4800Wp, SolarEdge SE5K, 15x JAM60S17/320, ZW 15º ┃ WTW: Zehnder Q600 ┃ SH: Home Assistant, Proxmox, Intel NUC 8i5 Mini


Acties:
  • 0 Henk 'm!

  • benoni
  • Registratie: November 2003
  • Niet online
Oh wacht... ik ging er helemaal van uit dat de Time Machine volume een servershare was (ik dacht aan Airport of zoiets). Ik gebruik ´t zelf niet namelijk, dus vandaar O-)

Een losse schijf eject´en is niet handig inderdaad, want die moet je handmatig weer aankoppelen. Daarentegen mag je zo´n schijf wel weer tijdelijk een andere naam geven, misschien dat daardoor backupd dan denkt dat de schijf is afgekoppeld. Dat weet ik niet helemaal zeker, maar je zou ´t kunnen proberen.

Ik heb wel ´t idee dat je met een shell script als gebruiker minder gezeur hebt, dus als ik (ooit) even tijd heb kan ik zijn dat ik daar even induik. Maar prik me er niet op vast ;)

Acties:
  • 0 Henk 'm!

  • benoni
  • Registratie: November 2003
  • Niet online
Okee, onderstaand stukje shell scripting spoort eigenlijk niet helemaal in dit topic, maar in het grote "handige scripts" topic zou het ook wat misplaatst zijn omdat het zo specifiek voor MacOSX is. Dus bij deze:

Bestand: /usr/local/bin/suspend-time-machine.sh
Bash:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh

# Suspends Time Machine when given applications are running.
# Written by: benoni
# License: free as in GPL

# Set $applications to match the application name:
#   applications="Adobe Photoshop"
# or use an extended grep pattern matching multiple application names:
#   applications="Adobe.*|Indesign.*"
#
applications="Adobe Lightroom 2"

# This script stops silently if its tools are not available
#
test -x /bin/ps || exit 0
test -x /usr/bin/grep || exit 0
test -x /usr/bin/defaults || exit 0
test -x /usr/bin/logger || exit 0

# Checks if any matching applications are running, and if Time Machine is set active
#
checkRunning=`ps acx | grep -c -E "$applications"`
checkService=`defaults read /Library/Preferences/com.apple.TimeMachine "AutoBackup"`

# If any of the programs are running, and Time Machine too, suspend it
#
if [[ $checkRunning != 0 && $checkService != 0 ]]; then
    defaults write /Library/Preferences/com.apple.TimeMachine "AutoBackup" -bool false
    logger "$0 - TimeMachine AutoBackup is set OFF"
fi

# If none of the programs are running, nor Time Machine, then make this service active
#
if [[ $checkRunning == 0 && $checkService == 0 ]]; then
    defaults write /Library/Preferences/com.apple.TimeMachine "AutoBackup" -bool true
    logger "$0 - TimeMachine AutoBackup is set ON"
fi

# Ready
#
exit 0


Bestand: /Library/LaunchDaemons/com.system.suspend-time-machine.plist
XML:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.system.suspend-time-machine</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/local/bin/suspend-time-machine.sh</string>
        </array>
        <key>LowPriorityIO</key>
        <true/>
        <key>Nice</key>
        <integer>1</integer>
        <key>StartInterval</key>
        <integer>20</integer>
</dict>
</plist>

Installatieprocedure: script en launchd-plist installeren in de opgegeven locaties, de toegang voor root instellen en voor gewone gebruikers ontzeggen (chown root && chmod 700).
Ook deze heb ik niet helemaal getest, dat laat ik weer aan breinonline over :>
Tip: Het script gebruikt 'logger', dus met 'tail /var/log/system.log' in Terminal kun je kijken of de Time Machine switch is aan- of uitgezet.

[ Voor 3% gewijzigd door benoni op 18-11-2008 19:13 ]


Acties:
  • 0 Henk 'm!

  • breinonline
  • Registratie: Juni 2001
  • Nu online

breinonline

Are you afraid to be known?

Ik heb weer getest :) Ik heb de bestanden op de juiste plaats gezet en de permissies veranderd. Ik krijg de volgende foutmeldingen in de console (en TM blijft aan):
code:
1
2
3
4
17/11/08 18:40:13 com.apple.launchctl.Aqua[105] launchctl: CFURLCreateDataAndPropertiesFromResource(/Library/LaunchAgents/suspend-time-machine.plist) failed: -10 
17/11/08 18:40:13 com.apple.launchctl.Aqua[105] launchctl: propertyList is NULL 
17/11/08 18:40:13 com.apple.launchctl.Aqua[105] launchctl: no plist was returned for: /Library/LaunchAgents/suspend-time-machine.plist 
17/11/08 18:40:13 com.apple.launchctl.Aqua[105] launchctl: no plist was returned for: /Library/LaunchAgents/suspend-time-machine.plist

WP: Mitsubishi Ecodan PUHZ-SHW112YAA, ERSC-VM2C, Procon ┃ PV: 4800Wp, SolarEdge SE5K, 15x JAM60S17/320, ZW 15º ┃ WTW: Zehnder Q600 ┃ SH: Home Assistant, Proxmox, Intel NUC 8i5 Mini


Acties:
  • 0 Henk 'm!

  • benoni
  • Registratie: November 2003
  • Niet online
Hier ook even getest O-)
  • In de XML code van mijn post zaten vreemde UTF tekens voor de spaties. Ik heb ze verwijderd.
  • Er stond nog een 'StartCalendarInterval' directive in, moet 'StartInterval' zijn. Op 20 seconden gezet.
  • Als je een job als root wilt draaien hoort deze in /Library/LaunchDaemons, niet /Library/LaunchAgents, lees ik op de interwebs B)

Acties:
  • 0 Henk 'm!

  • breinonline
  • Registratie: Juni 2001
  • Nu online

breinonline

Are you afraid to be known?

Wederom aangepast. De boel lijkt nu te werken, ik krijg in de console te zien:
code:
1
2
3
18/11/08 18:20:37 reinier[3908] /usr/local/bin/suspend-time-machine.sh - TimeMachine AutoBackup is set OFF 
18/11/08 18:21:28 fseventsd[41] callback_client: ERROR: d2f_callback_rpc() => (ipc/send) invalid destination port (268435459) for pid 3899 
18/11/08 18:21:57 reinier[3943] /usr/local/bin/suspend-time-machine.sh - TimeMachine AutoBackup is set ON

Alleen als ik bij TM preferences kijk, dan gaat TM netjes op OFF door het script, maar niet meer op ON. Bovendien lijkt TM ook niet uit zichzelf te gaan backuppen. Als ik handmatig kies voor backup now dan wordt er netjes een backup gedraaid, maar veranderd er ook niets aan de status.

WP: Mitsubishi Ecodan PUHZ-SHW112YAA, ERSC-VM2C, Procon ┃ PV: 4800Wp, SolarEdge SE5K, 15x JAM60S17/320, ZW 15º ┃ WTW: Zehnder Q600 ┃ SH: Home Assistant, Proxmox, Intel NUC 8i5 Mini


Acties:
  • 0 Henk 'm!

  • benoni
  • Registratie: November 2003
  • Niet online
breinonline schreef op dinsdag 18 november 2008 @ 19:05:
Alleen als ik bij TM preferences kijk, dan gaat TM netjes op OFF door het script, maar niet meer op ON.
Probeer nog even deze aanpassingen in het script:
code:
1
2
(regel 29) defaults write /Library/Preferences/com.apple.TimeMachine "AutoBackup" -bool false
(regel 36) defaults write /Library/Preferences/com.apple.TimeMachine "AutoBackup" -bool true

Acties:
  • 0 Henk 'm!

  • breinonline
  • Registratie: Juni 2001
  • Nu online

breinonline

Are you afraid to be known?

_/-\o_ Het werkt! Ontzettend bedankt!

WP: Mitsubishi Ecodan PUHZ-SHW112YAA, ERSC-VM2C, Procon ┃ PV: 4800Wp, SolarEdge SE5K, 15x JAM60S17/320, ZW 15º ┃ WTW: Zehnder Q600 ┃ SH: Home Assistant, Proxmox, Intel NUC 8i5 Mini

Pagina: 1