Controlling Tunnelblick with AppleScript
This document is about making Tunnelblick do things via scripting. Tunnelblick itself also uses scripts; see Using Scripts.
AppleScripts may connect, disconnect, or list Tunnelblick configurations.
Please note that the verbs only initiate actions. The "connect" verb, for example, is the equivalent of clicking the "Connect" button. It returns immediately after starting an attempt to connect using a particular configuration and does not indicate the connection has been accomplished successfully.
For an example of using Tunnelblick's AppleScript support to solve a particular problem, see this discussion.
Controlling Tunnelblick from the Command Line
You can invoke AppleScript from the command line to control Tunnelblick. You can connect, disconnect, and list configurations.
One way is to store the AppleScript in a file and then invoke it with
Another way is to include the AppleScript commands in the command line with, for example,
osascript -e "tell application \"/Applications/Tunnelblick.app\"" -e "connect \"configuration-name\"" -e "end tell"
replacing configuration-name with the name of your configuration.
To display the AppleScript commands that are supported by Tunnelblick (or any application), open /Utilities/Script Editor, then click the "File", then "Open Dictionary", and select the application.
tell application "Tunnelblick"
disconnect (get name of second configuration)
connect (get name of first configuration where state = "EXITING")
disconnect all except when computer starts
get state of second configuration
get state of first configuration where name = "Work"
get name of configurations
get state of configurations
get autoconnect of configurations
save username "john.bull" for "Work"
save password "password123" for "Work"
save passphrase "passphrase123" for "Work"
delete all credentials for "Work"