AppleScript |将 PPTP VPN 设置部署到 MAC 客户端
需要一个 applescript(我以前没有使用过)来在我们的远程工作人员的 mac 盒子上部署我们的 VPN 连接设置。这是用于 PPTP VPN 的。
通过谷歌搜索,我发现了以下链接:
http://discussions.apple.com/thread.jspa?messageID=10368307
但我还是不能:
a) 似乎为 VPN 连接命名
b) 给它一个 pptp vpn 服务器地址
c) 提供 DNS、默认网关和任何自定义路由以使该 VPN 正常工作。
我如何添加这些字段/输入?
告诉应用程序“系统偏好设置”
显示窗格“网络”
激活
告诉应用程序“系统事件”
告诉进程“系统偏好设置”
告诉窗口 1
单击按钮“添加服务”
告诉表 1
单击弹出按钮 1
点击弹出按钮1的菜单1的菜单项“VPN”
延迟1
点击弹出按钮2
点击弹出按钮2的菜单1的菜单项“PPTP”
单击按钮“创建”
结束告诉
单击按钮“应用”
结束告诉
结束告诉
延迟 1 — 可选(仅用于视觉反馈)
使用 {command down} 击键“w”
结束告诉
结束告诉
似乎可以很好地创建连接,但没有详细信息 - 我不确定我将使用什么语法来实现此目的。
感谢您的投入!
问候
谢谢
Need an applescript (which I haven't used before) to deploy our VPN connection settings on our remote workers mac boxes. this is for PPTP VPN.
Upon googling I came across the following link :
http://discussions.apple.com/thread.jspa?messageID=10368307
But still I can't :
a) seem to name the VPN connection
b) give it a pptp vpn server address
c) give dns, default gateway and any custom routes for this vpn to work.
How can I add those fields / enteries in ?
tell application “System Preferences”
reveal pane “Network”
activate
tell application “System Events”
tell process “System Preferences”
tell window 1
click button “Add Service”
tell sheet 1
click pop up button 1
click menu item “VPN” of menu 1 of pop up button 1
delay 1
click pop up button 2
click menu item “PPTP” of menu 1 of pop up button 2
click button “Create”
end tell
click button “Apply”
end tell
end tell
delay 1 — optional (just for visual feedback)
keystroke “w” using {command down}
end tell
end tell
The above script seems to create the connection just fine but without the details - and I am not sure about what syntax I would use to get this going.
Thanks for your input!
Regards
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Rihatum,这是完整的 Applescript,其中包含您想做的所有事情。
Rihatum, here's the full Applescript with all the things you want to do.
古老的答案
我尝试使用网络设置工具解决方案,但它对我不起作用:SI 实际上使用 UI 自动化想出了一个成功的脚本。它在这里发布了一篇关于它的文章: https://web.archive.org/web/20160731014105/http://blog.affirmix.com/2011/01/ 12/how-to-configure-a-vpn-in-mac-os-x-usingapplescript/
复制/粘贴答案
免责声明:这已经有 12 多年的历史了,是为 Mac OS 编写的X 版本以猫命名。里程可能会有所不同,请自行承担使用风险,如果不进行修改,它可能无法工作,yada yada...希望它为更好的答案提供基础:)
如果您要设置 Cisco IPSec VPN,则以下是“Sergio 的评论”供参考:
Ancient answer
I tried the solution using the networksetup tool, but it didn't work for me :S I actually came up with a successful script using UI automation. It put up a post about it here: https://web.archive.org/web/20160731014105/http://blog.affirmix.com/2011/01/12/how-to-configure-a-vpn-in-mac-os-x-usingapplescript/
Copy/pasted answer
Disclaimer: This is now 12+ years old, and was writen for a Mac OS X version named after a cat. Milage may vary, use at your own risk, it probably won't work without modifications, yada yada... Hopefully it provides a foundation for a better answer :)
If you are setting up a Cisco IPSec VPN, then here is "Sergio's comment" for reference:
我认为你想要做的是使用networksetup命令构建一个脚本
并在 AppleScript 中使用一系列“do shell script”行,而不是尝试使用 GUI 脚本进行配置。
例如,在 AppleScript 中,此命令将在以太网接口上创建新的 VPN PPTP 连接
:您将使用以下路由器 IP:
(-setmanual networkservice ip 子网路由器)
之后,您可以使用其他选项来配置其余部分。例如,
要将 DNS IP 添加到新创建的 VPN PPTP 连接,您可以将其添加到 AppleScript:
查看网络设置命令的手册页。它可以做很多事情。另外,您可以在 Google 上搜索该命令,您会发现很多论坛,人们在讨论 Mac 命令行网络配置。单个关键字 networksetup 效果不太好,因为它返回很多 Windows 页面,因此 Google 搜索“sudo networksetup”,这将返回 Mac 相关页面。
I think what you want to do is build a script using the networksetup command
and use a series of "do shell script" lines in your AppleScript instead of trying to GUI script the configuration.
Fo example, in your AppleScript this command will create a new VPN PPTP connection on the ethernet interface:
To set the IP, subnet, & router IPs you would use this:
( -setmanual networkservice ip subnet router )
After that you can use the other options to configure the rest. For example,
to add a DNS IP to your newly created VPN PPTP connection you would add this to your AppleScript:
Check out the man page for the networksetup command. It does a tremendous amount of things. Also, you can Google that command and you will find a lot of forums with people discussing Mac command line network configurations. The single keyword networksetup doesn't work too well because it returns a lot of Windows pages so Google for "sudo networksetup" and that will return Mac related pages.