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)
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)
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.)
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.
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"
activatetell application "System Events"
...
or just do this in a simpler way without GUI, but both of them would be good for me!
Thank you!
Maybe?
#!/bin/bash
networksetup -createnetworkservice {networkservicename} {hardwareport}
not sure what to put on hardwareport...
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.
super! thanks a lot!
My pleasure. (I love easy questions like that.) 😉
Applescript to start a private network