doku:applescript
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
— | doku:applescript [2014-11-15 14:09] (aktuell) – angelegt - Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | ====== AppleScript ====== | ||
+ | ===== Mein erstes AppleScript ===== | ||
+ | | ||
+ | * Skripteditor starten | ||
+ | * Script: < | ||
+ | set ACTION to 0 | ||
+ | display dialog the (" | ||
+ | |||
+ | |||
+ | if the button returned of the result is "nur Backup" | ||
+ | set ACTION to 1 | ||
+ | else | ||
+ | if the button returned of the result is " | ||
+ | set ACTION to 2 | ||
+ | end if | ||
+ | |||
+ | end if | ||
+ | |||
+ | if ACTION > 0 then | ||
+ | set OUT to do shell script (" | ||
+ | (* bei Fehler Abbruch durch AppleScript, | ||
+ | if ACTION = 1 then | ||
+ | display dialog " | ||
+ | |||
+ | " & OUT buttons {" | ||
+ | end if | ||
+ | end if | ||
+ | |||
+ | if ACTION > 1 then | ||
+ | display dialog (" | ||
+ | (* tell application " | ||
+ | end if | ||
+ | </ | ||
+ | * Speichern als " | ||
+ | * " | ||
+ | ===== Starte Terminal und ssh ===== | ||
+ | < | ||
+ | tell application " | ||
+ | do script with command "ssh user@server.de" | ||
+ | set name_of_window to (get name of front window) | ||
+ | set id_of_window to (get id of front window) | ||
+ | set active_tab_of_window to (get selected tab of window id id_of_window) as record | ||
+ | set active_tab_of_window_record to active_tab_of_window as list | ||
+ | set active_tab_of_window_record_id to (get item 3 of active_tab_of_window_record) as integer | ||
+ | set custom title of tab active_tab_of_window_record_id of window id id_of_window to " | ||
+ | activate | ||
+ | end tell | ||
+ | </ | ||
+ | |||
+ | * "fast alles am Ende" ist nur um den titel zu setzen. Geht das auch einfacher ? | ||
+ | * " | ||
+ | |||
+ | 2. Version: ermittel den eigenen Dateinamen, um damit den Zielrechner zu bestimmen (dann reich ein einfaches Kopieren der Datei für einen neuen Server). | ||
+ | < | ||
+ | tell application " | ||
+ | |||
+ | # eigenen Dateinamen ermitteln (ohne Pfad und ohne .app) -> myName | ||
+ | set myPath to path to me as text | ||
+ | if myPath ends with ":" | ||
+ | set n to -2 | ||
+ | else | ||
+ | set n to -1 | ||
+ | end if | ||
+ | set AppleScript' | ||
+ | set myName to text item n of myPath | ||
+ | if (myName contains " | ||
+ | set AppleScript' | ||
+ | set myName to text 1 thru text item -2 of myName | ||
+ | end if | ||
+ | set AppleScript' | ||
+ | |||
+ | set Hostname to myName | ||
+ | |||
+ | set Terminalfenster_1 to (make new terminal) | ||
+ | tell Terminalfenster_1 | ||
+ | #set number of columns to 80 | ||
+ | #set number of rows to 25 | ||
+ | |||
+ | set Tab_1 to (make new session at the end of sessions) | ||
+ | tell Tab_1 | ||
+ | activate | ||
+ | set name to Hostname | ||
+ | #set background color to " | ||
+ | #set foreground color to " | ||
+ | #set transparency to " | ||
+ | exec command "/ | ||
+ | write text "ssh " & Hostname | ||
+ | end tell -- Tab_1 | ||
+ | end tell -- Terminalfenster_1 | ||
+ | end tell | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Starte Chicken of the Vnc Sitzung ===== | ||
+ | < | ||
+ | do shell script (" | ||
+ | </ | ||
+ | |||
+ | Besonderheiten: | ||
+ | * Script läuft im Hintergrund (''&> | ||
+ | * '' | ||
+ | * Parameter für Chicken (starte Programm direkt mit '' | ||
+ | |||
+ | ===== Mail.app: Account (de-)aktivieren ===== | ||
+ | < | ||
+ | tell application " | ||
+ | set ist_aktiv to (get enabled of account " | ||
+ | set enabled of account " | ||
+ | end tell | ||
+ | </ | ||
+ | |||
+ | ===== iTerm mit mehreren Tabs und mit Kommandos ===== | ||
+ | < | ||
+ | set box_user to " | ||
+ | set my_boxes to {„host1.de“, | ||
+ | set ssh_opt to "-L 4040: | ||
+ | set my_cmd to {"sudo bash", " | ||
+ | |||
+ | tell application " | ||
+ | activate | ||
+ | set t to (make new terminal) | ||
+ | tell t | ||
+ | (* Loop over the boxes, create a new tab and connect. *) | ||
+ | repeat with box in my_boxes | ||
+ | activate current session | ||
+ | launch session " | ||
+ | tell the last session | ||
+ | set conn to "ssh " & ssh_opt & box_user & " | ||
+ | set name to box_user & " | ||
+ | write text conn | ||
+ | repeat with cmd in my_cmd | ||
+ | write text cmd | ||
+ | end repeat | ||
+ | end tell | ||
+ | end repeat | ||
+ | end tell | ||
+ | end tell | ||
+ | </ | ||
+ | |||
+ | ===== Links ===== | ||
+ | * http:// | ||
+ | * [[applescriptcopy]] |