A command line tool to handle PPP connections

Nov 03, '04 08:48:00AM

Contributed by: bolet

I needed a way to stop and restart my PPP connection (pppoa/dsl). Killing pppd worked to stop the connection, but even with the exact same arguments obtained via ps laxww, the reconnection didn't work.

There is no command tool (to my knowledge) that does such a simple thing as to establish the default connection (as defined in the System Preferences). I tried an AppleScript (which I could call from command line) to send the Internet Connection application the connect message. But I felt that this was inelegant. And the trick would work only when logged in.

So I wrote a small tool using the SCNetworkConnection API, which can query the status of the default connection, start it, stop it and force-stop it (even if it is used by other apps). This is guaranteed to stay in sync with the GUI, and correctly notify running processes, because it uses Apple's own "high level" system calls.

The tool, along with the Xcode project and source, is freely available for download [PPPConnect.tgz -- 12KB]. I hope this can be of use to some of you.

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20041102213340509