I am looking for a way to initiate a PPP connection with my EVDO modem from the command line instead of having to go to System Preferences -> Network and hit "Connect".
To connect a network device, use the
System Events dictionary:
tell application "System Events" tell current location of network preferences connect service "Sprint 3G" end tell end tell
assuming the name of the service is
To disconnect, change
tell application "System Events" tell current location of network preferences disconnect service "Sprint 3G" end tell end tell
Once you've saved your scripts with names, you can use the terminal
open command to kick off either script.
I'm sure there is a more elegant way, but this could be done with UI scripting. I don't have an EVDO modem, so I can't give the specifics of the script that would work, but first you would go to -> System Preferences -> Universal Access and make sure "Enable access for assistive devices" is checked.
Then, you could write a script using a text editor. As I said, the specifics of the script would depend on your system and the layout of the screen you're trying to control, but it would look something like this:
tell application "System Preferences"
set the current pane to pane id "com.apple.preference.network"
click button 1
tell application "System Preferences" to quit
You'd save the script, make it executable, and then you could enable your modem from the command line. I'm sure there's a more elegant way that doesn't involve popping up a window and that doesn't involve so much trial and error at the "click button 1" stage, but this is a start.
I think this can be done using pppd. You'll need to find the device name (/dev/tty...) and read through the long list of available options but it looks like that could work.