Applescript与Tunnelblick选择随机VPN
我一直在尝试编写一个简单的applescript,以获取可用VPN连接的列表并随机选择一个,如下所示:Applescript与Tunnelblick选择随机VPN,applescript,Applescript,我一直在尝试编写一个简单的applescript,以获取可用VPN连接的列表并随机选择一个,如下所示: 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
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
这将返回:
应用程序“Tunnelblick”的配置“USA.Indiana.SouthBend_LOC1S2.UDP”
但是,如果我尝试通过替换返回来连接:
connect generated_choice --displays the choice
我得到一个错误:
Tunnelblick出现错误:无效的密钥表单
为什么会发生这种情况?它似乎是在传递数组(列表)而不是值。下面的操作有效
connect(获取(配置选择)的名称)
以下步骤已完成
connect(获取(配置选择)的名称)