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 (and quoting the name if it contains spaces).
application n :
configuration n : A VPN configuration.
contained by application.
name (text, r/o) : Name of the configuration.
state (text, r/o) : State of the configuration.
autoconnect (text, r/o):
bytesIn (text, r/o) :
bytesOut (text, r/o) :
connect v : Connect a VPN configuration.
connect text : Name of configuration to connect.
disconnect v : Disconnect a VPN configuration.
connect all v : Connect all unconnected VPN configurations.
disconnect all v : Disconnect all connected VPN configurations.
disconnect all except when computer starts v : Disconnect all connected VPN configurations except 'when computer starts' configurations.
added or removed configurations v : Tells Tunnelblick that configurations have been added or removed, so it can update the menu and the list of configurations in the "VPN Details" window.
changed openvpn configuration file for v : Tells Tunnelblick that an OpenVPN configuration file has been modified, so it can update settings in the "VPN Details" window.
changed openvpn configuration file for text : Name of configuration for which the OpenVPN configuration file has been modified.
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