Seit 10.6 nutze ich die in Mac OS X integrierte VPN-Lösung um mich mit dem WLAN meiner Uni zu verbinden. Mit dem Cisco VPN Client konnte ich es damals noch mit einem Trick umgehen jedes mal das Passwort eingeben zu müssen. Jetzt habe ich auch eine Möglichkeit für den nativen Client gefunden.
Das Script basiert in Teilen auf Code von Corey Gilmore
Es handelt sich um ein AppleScript, welches man nur in den eingebauten „Scripteditor“ von Mac OS X kopieren muss. Es gilt natürlich bezüglich gespeicherter Passwörter, was ich hier schon gesagt hab und das was Corey in seinem Artikel auch schreibt:
Disclaimer
This is not endorsed or recommended by Apple, Cisco or RSA, and is quite possibly in violation of your corporate policies, especially if you store your PIN in the file.
Die Variablen „thePassword“ und „Uni VPN“ muss man sich natürlich noch individuell anpassen. Anschließend als Skript oder Programm speichern und z.b. ins Dock ziehen. Fertig!
Verbindet man das ganze noch mit SleepWatcher so wie hier kann man sich sogar automatisch beim aufwachen aus dem Ruhezustand verbinden, fast als wäre man im heimischen WLAN.
Achtung bei nicht deutsch lokalisiertem OS muss man „theText“ durch den entsprechenden Text des Passwortdialoges ersetzen (Der der im Screenshot zu sehen ist).
[codesyntax lang=“applescript“ blockstate=“collapsed“]
set theApp to "UserNotificationCenter" -- shouldn't have to change this set theText to "VPN-Verbindung" -- static text to search for in the VPN dialog, likely locale specific set theVpn to "Uni VPN" set thePassword to "12345"
--VPN-Verbindung herstellen tell application "System Events" tell current location of network preferences set VPNservice to service theVpn if exists VPNservice then connect VPNservice end tell end tell --Passworteingabefenster finden delay 0.2 repeat with x from 1 to 20 log "vc loop " & x delay 0.1 set winNum to find_window_by_static_text(theApp, theText) log "winNum is: " & winNum if winNum is not null then exit repeat end if end repeat --Passwort eingeben if winNum is null then log "Could not find the VPN Connection window" return null end if tell application theApp to activate tell application "System Events" perform action "AXRaise" of item winNum of (get every window of application process theApp) keystroke thePassword key code 36 end tell --Code from: ------------------------------------------------ -- Automated token generation and VPN logins -- Copyright 2010, Corey Gilmore -- http://coreygilmore.com/ -- Last Modified: 2010-02-04 ------------------------------------------------ -- Find a window containing specific static text, in a given application on find_window_by_static_text(appname, staticText) log "Searching " & appname & " for " & staticText tell application "System Events" set allApps to (get name of every application process) -- get all apps if allApps contains appname then -- find the app if it's running set allWin to (get every window of application process appname) -- get all the windows for our app set numWin to count allWin -- count the number of windows repeat with winNum from 1 to numWin set aWin to window winNum of application process appname set allText to (get value of every static text of aWin) if allText contains staticText then log "fwbst winnum: " & winNum return winNum end if end repeat end if end tell return null end find_window_by_static_text
[/codesyntax]