Sharing script: auto opening PPPoE connection with "Internet Connect"

Hello,

I wanted a script for automatically reconecting my internet services (PPPoE for me) after uncommon failures. I’ve found that many people complained about a bug in “Internet Connect” script dictionary (on System 10.3), because it does not connect and does not explains correctly the configuration for connection!

So, here it is my final code (thanks to many different answers found in this forum!). Be sure to enable System Preferences => Universal Access => Access for Assistive Devices (on System 10.3).


(* Connection state codes, got after many trials:
0 = Idle (not connected) 
1 = Dialing... 
2 = Connecting... 
3 = Error 
4 = Connected (antes da autenticacao) 
5 = Disconnecting... (as reported by others) 
7 = authenticating (?)
8 = Connected (on my system) 
9 = Disconnecting... (on my system) 
10 = Could not connect (on my system)
*)
tell application "Internet Connect"
	set estado to the state of the status of PPPoE configuration "Built-in Ethernet"
	if estado is 8 then return
	activate
end tell
-- source: http://www.apple.com/applescript/uiscripting/index.html
tell application "System Events"
	tell process "Internet Connect"
		tell menu bar 1
			tell menu bar item "Connect"
				tell menu "Connect"
					click menu item "Connect"
				end tell
			end tell
		end tell
	end tell
end tell
return true

For the following step, open terminal window and create another script file (be sure to add an empty line after the last command):


osascript yourpath/AboveScriptName.scpt
at -f ~/pathForThisFile/thisFileName now + 5 minutes

Please, remember to make this file executable:

chmod u+x

And you must enable “at” command. Typing “man at” explains why:

[i]
at, batch, atq, atrm are all disabled by default on Mac OS X. Each of
these commands depend on the execution of atrun(8) which has been dis-
abled due to power management concerns. Those who would like to use
these commands, must first re-enable /usr/libexec/atrun by removing the
leading ‘#’ from the line

 #*/5    *       *       *       *       root    /usr/libexec/atrun
 in the file /etc/crontab.  /etc/crontab must be edited by root.

[/i]

Typing the following command easily edits the crontab:
sudo pico /etc/crontab

Now, run the last script and enjoy freedom! I hope it is useful for you as it is for me. Anyone has a better/smaller solution? Thanks to everybody in this forum, who kindly shares code and explains the basics for the begginers!

Zoltan Paulinyi
http://www.musicaerudita.com

Model: iMac
AppleScript: 1.9.3
Browser: Safari 312
Operating System: Mac OS X (10.3.9)

Hi, paulinyi.

I don’t have 10.3, so I can’t check out the “bug”. I’ve not heard of it myself. If your System Events script works, this should too:

tell application "Internet Connect"
	connect -- uses the current configuration
end tell

Otherwise there’s this. (The PPP equivalent works on my machine in 10.2.):

tell application "Internet Connect"
	connect PPPoE configuration "Built-in Ethernet" -- uses your PPPoE configuration explicitly
end tell

Thanks for your reply! You are right, it would be quite easier if it works! You can shearch/find in this forum other messages (mostly from year 2002/3) about this bug in version 10.3. I wanted to share my final and complete version.