Basically, I wrote a script to kill the network (wifi as of now, will try and figure out ethernet in a bit) when the vpn disconnects. I wanted to add a failsafe that also killed applications, but when I added this bit of code
to the script, I kept having trouble with running it. I'm honestly not sure how the ifs are supposed to be used in this situation.
I want it to do the following
but I'm not really sure how to do that / everything I have done has failed. This ****is my code.
That's what's failing. Everything I have tried has something wrong. And correction/guidance/advice/help would be GREATLY appreciated. I either get an error that is complaining about the way I phrase the if statement, or I get an error that is saying error
but when I enter the following into a blank script, without the rest, they work fine and don't give that error
PHP:
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"
to the script, I kept having trouble with running it. I'm honestly not sure how the ifs are supposed to be used in this situation.
I want it to do the following
PHP:
- 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 Palring**b**"
but I'm not really sure how to do that / everything I have done has failed. This ****is my code.
PHP:
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
That's what's failing. Everything I have tried has something wrong. And correction/guidance/advice/help would be GREATLY appreciated. I either get an error that is complaining about the way I phrase the if statement, or I get an error that is saying error
Code:
"iTunes got an error: Cant get running." number -1728 from «class runn»
but when I enter the following into a blank script, without the rest, they work fine and don't give that error
PHP:
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"