Sunday, November 29, 2020

#1 2007-11-02 08:54:34 am

bbjonz
Member
Registered: 2007-06-25
Posts: 3

How to Script VPN Connect in Leopard?

Hi Everyone,

I have a relatively simple script that automates a VPN connection (using Apple's VPN Connect) to my wife's work server.  It simply told the application Internet Connect to activate, and the rest would take care of itself.  But Leopard doesn't have Internet Connect as a freestanding application.  Rather, VPN connections are now within the Network preference pane.  So, how do I tell AS to launch a VPN connection from inside Leopard's Network Prefs?  I think it should be simple, but I couldn't find any clues online.  Thanks in advance.

Joe

Offline

 

#2 2007-11-02 10:26:14 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11699
Website

Re: How to Script VPN Connect in Leopard?

Hi,

the scriptability of network preferences has been massively improved in Leopard

Try this

Applescript:

tell application "System Events"
   tell current location of network preferences
       set VPNservice to service "VPN (L2TP) 2" -- name of the VPN service
       if exists VPNservice then connect VPNservice
   end tell
end tell


regards

Stefan


Filed under: System

Offline

 

#3 2007-11-02 12:01:51 pm

bbjonz
Member
Registered: 2007-06-25
Posts: 3

Re: How to Script VPN Connect in Leopard?

Thanks, Stefan!  I'll give it at try when I get home.  I figured it would be improved in Leopard, but it wasn't obvious to me how to identify the VPN's location.  It makes perfect sense, though, given your code.

Joe

Offline

 

#4 2007-11-03 11:17:56 am

bbjonz
Member
Registered: 2007-06-25
Posts: 3

Re: How to Script VPN Connect in Leopard?

Hi Stefan (and Everyone),

It worked like a charm.  May I impose on you, though, for one last bit of help?  How do I check if the VPN is active?  With Internet Connect it was pretty simple, but not sure how to do it in Leopard.  The idea is to make sure the VPN is connected before mounting network drives.  Thanks in advance.

Joe

Offline

 

#5 2007-11-03 11:37:49 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11699
Website

Re: How to Script VPN Connect in Leopard?

try this

Applescript:


tell application "System Events"
   tell current location of network preferences
       set VPNservice to service "VPN (L2TP) 2" -- name of the VPN service
       set isConnected to connected of current configuration of VPNservice
       if isConnected then
           -- do something
       end if
   end tell
end tell


regards

Stefan


Filed under: System

Offline

 

#6 2008-02-11 02:01:41 pm

Rush
Member
Registered: 2008-02-11
Posts: 2

Re: How to Script VPN Connect in Leopard?

That's great for a VPN, but I use to use tell "internet connect" to connect, to dail up to the internet. Now all my scripts don't work anymore in Leopard.

Offline

 

#7 2008-02-11 02:17:46 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11699
Website

Re: How to Script VPN Connect in Leopard?

Rush wrote:

That's great for a VPN, but I use to use tell "internet connect" to connect, to dail up to the internet. Now all my scripts don't work anymore in Leopard.


Internet Connect.app has vanished in Leopard, use network preferences in System Events instead


regards

Stefan

Offline

 

#8 2008-02-12 08:49:32 am

Rush
Member
Registered: 2008-02-11
Posts: 2

Re: How to Script VPN Connect in Leopard?

I missed the
    --tell current location of network preferences--
now it works!!

I do it like this now:

Applescript:

tell application "System Events"
   tell current location of network preferences
       set Modemdailup to service "HUAWEI"
       if exists Modemdailup then connect Modemdailup
   end tell
end tell

Last edited by Rush (2008-02-12 08:50:23 am)


Filed under: System

Offline

 

#9 2008-09-18 09:46:24 am

amet
Member
Registered: 2008-04-04
Posts: 5

Re: How to Script VPN Connect in Leopard?

sorry to bring this  back from dead,

I am trying to get the "time connected" of current modem connection.

its the time that shows on menu bar and tells how long you have been connected to internet via modem.

on "Internet Connect" it was seconds connected.

any ideas?
thanks alot

Last edited by amet (2008-09-19 12:30:13 am)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)