【发布时间】:2013-08-03 02:48:49
【问题描述】:
基本上,当 vpn 断开连接时,我编写了一个脚本来终止网络(wifi 到现在,将尝试找出以太网)。我想添加一个也杀死应用程序的故障保护,但是当我添加这段代码时
if application "iTunes" is running then do shell script "killall iTunes"
if application "uTorrent" is running then do shell script "killall uTorrent"
if application "Transmission" is running then do shell script "killall Transmission"
if application "Safari" is running then do shell script "killall Safari"
if application "Google Chrome" is running then do shell script "killall 'Google Chrome'"
if application "Palringo" is running then do shell script "killall Palringo"
对于脚本,我一直无法运行它。老实说,我不确定在这种情况下应该如何使用 ifs。
我希望它执行以下操作
- if myConnection is not null and
- if vpn is not connected
- kill wifi
- and also do the following "if statements":
if application "iTunes" is running then do shell script "killall iTunes"
if application "uTorrent" is running then do shell script "killall uTorrent"
if application "Transmission" is running then do shell script "killall Transmission"
if application "Safari" is running then do shell script "killall Safari"
if application "Google Chrome" is running then do shell script "killall 'Google Chrome'"
if application "Palringo" is running then do shell script "killall Palringo"
b*ut 我不确定该怎么做/我所做的一切都失败了。这是我的代码。*
on idle
tell application "System Events"
tell current location of network preferences
set myConnection to the service "BTGuard VPN"
if myConnection is not null then
if current configuration of myConnection is not connected then do shell script "/usr/sbin/networksetup -setairportpower en1 off"
if application "iTunes" is running then do shell script "killall iTunes"
if application "uTorrent" is running then do shell script "killall uTorrent"
if application "Transmission" is running then do shell script "killall Transmission"
if application "Safari" is running then do shell script "killall Safari"
if application "Google Chrome" is running then do shell script "killall 'Google Chrome'"
if application "Palringo" is running then do shell script "killall Palringo"
end if
end tell
return 0
end tell
end idle
这就是失败的原因。我所尝试的一切都有问题。我们将不胜感激更正/指导/建议/帮助。
【问题讨论】:
标签: macos applescript vpn kill