我一直试图编写一个简单的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得到了一个错误:无效的键形式。
为什么会发生这种事?似乎它传递的是数组(列表),而不是值。
发布于 2013-01-11 03:39:26
后续工作
connect (get name of (configuration pick))
https://stackoverflow.com/questions/14186068
复制相似问题