I’ve been trying to write a simple applescript to get a list of availible VPN connections and pick a random one, here it is:
tell application "Tunnelblick"
set the_values_list to get configurations
set the list_count to the count of the_values_list --gets number of items in list
set pick to random number from 1 to list_count --has it choose a random item
set generated_choice to item pick of the_values_list --sets the generated item as the choice
return generated_choice --displays the choice
end tell
This returns:
configuration “USA.Indiana.SouthBend_LOC1S2.UDP” of application “Tunnelblick”
However if I try to connect by replacing the return:
connect generated_choice --displays the choice
I get an error:
Tunnelblick got an error: Invalid key form.
Why could this be happening? It seems like it’s passing in arrays (list) pocked instead of the value.
Following worked
connect (get name of (configuration pick))