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".

  • You might be able to use two terminal windows to determine where your pppd script is stored. One window running opensnoop, the other fs_usage (without your modem, it's hard to guess where your scripts are stored) – bmike Aug 30 '11 at 13:51

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 Sprint 3G:

Screenshot of Sprint 3G

To disconnect, change connect to disconnect:

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.

  • Well done! I hope you don't mind me adding an open command to finish this off in the terminal way. – bmike Aug 31 '11 at 5:06
  • Looks great. I ended up using this with Alfred so I could just type connect 3g or disconnect 3g. – eric Aug 31 '11 at 5:11
  • Here's what a screenshot of the Alfred integration looks like: img.skitch.com/20110831-pg1nht8jbnb46nwgx27saw2uxc.png – eric Aug 31 '11 at 5:19
  • How do you call Alfred from the command line? Perhaps you just meant to script it in response to a shortcut key. – bmike Aug 31 '11 at 13:53
  • Yes, I just mean that I was able to use the script in response to a keyword in Alfred. – eric Sep 1 '11 at 7:06

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 would really like to find a way to do it without needing to actually open the System Preferences. – eric Aug 30 '11 at 4:03
  • Of course. As I said, my approach is distinctly inelegant, but still scriptable. I'd love to see a better answer, and I suspect something involving pppd is more likely to be viable, but I have less advice to offer on that front. – Daniel Aug 30 '11 at 4:40

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.

  • I don't have a modem anymore to test this unfortunately, but I have used it in the past. (This is exactly what's used for modem connections in linux, for example.) If this answer is "negatively helpful" I would appreciate learning why it was downvoted with a comment. – Andrew Vit Sep 7 '11 at 2:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .