Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Applescript与Tunnelblick选择随机VPN_Applescript - Fatal编程技术网

Applescript与Tunnelblick选择随机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

我一直在尝试编写一个简单的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 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(获取(配置选择)的名称)