Applescript to start a private network

Hi all,

I'm just wondering if an applescript could be able to create setup and start a private network.

Thanks!

mac mini, Mac OS X (10.6.4)

Posted on Apr 27, 2012 12:20 AM

Reply
9 replies

Apr 27, 2012 9:35 AM in response to personal_username

A bash script with the networksetup command probably can do what you need. See here and here and here for some general examples; that lattermost link is AppleScript calling networksetup to establish a VPN.


It's also possible to set up and manage the network configuration on an OS X client system, using some more advanced tools, such as MCX. Here's a slightly stale overview of managing OS X client systems.


(And an opinion: Applescript is very good for automating the operations of a GUI app, but it's somewhat clunky for tasks that involve much more than that. I usually find using something written in a scripting language (bash, Python, etc) to be preferable.)

Apr 27, 2012 9:40 AM in response to personal_username

Kind of light on details there. What is it you're trying to do?


You say 'create'.. does this mean add the configuration data to a machine that's never connected to the VPN before?, or do you just mean establish the secure connection?


What kind of VPN connection? One setup via System Preferences -> Network (e.g. a PPTP or L2TP VPN)? or an SSL-based VPN that's initiated via a browser?


If you're just looking for an easy way to establish a VPN connection, check out the auto-connect options in System Preferences -> Network -> VPN - it can be configured to auto-start the VPN connection whenever you attempt to access a specific hostname or network. This might remove the need for a scripted front-end at all.

Apr 27, 2012 8:43 PM in response to personal_username

Ok, first of all thank you for your posts.

What I'm trying to do is actually much simpler thatn what you suggest, i think i wasn't clear enough, sorry.

I just need to simulate the "create network" in "System Preferences>Network>Network Name".

Then just press create!


I don't know if i need something like this


tell application "System Preferences"

reveal pane "Network"


activate

tell application "System Events"

...

or just do this in a simpler way without GUI, but both of them would be good for me!

Thank you!

Apr 28, 2012 9:51 AM in response to personal_username

I just need to simulate the "create network" in "System Preferences>Network>Network Name".

Then just press create!


Then you might want to try this:


tell application "System Preferences"

activate

reveal pane id "com.apple.preference.network"

tell application "System Events" to tell process "System Preferences"

delay 0.1

click pop up button "Network Name:" of group 1 of window "Network"

delay 0.1

key code 121 -- to select the last menu item

keystroke return

delay 0.1

keystroke return

end tell

end tell

The three “delay 0.1” statements are just for caution and might possibly be removed.


Message was edited by: Pierre L.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript to start a private network

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.