until i recently updated to panther 10.3 i used a wonderful miniscript the connected me to the internet on startup or reconnected me after an external disconnect. it’s actually half perl, half apple script:
hiere it is:
#!/usr/bin/env perl
$IFCONFIG=`/sbin/ifconfig -a`;
$CONNECT=1;
@LS =split(/x0a/, $IFCONFIG);
for $l(@LS){
$CONNECT=0 if $l=~m/ppp0/;
}
if($CONNECT){
system("osascript -e 'tell application "Internet Connect" to connect configuration "Ethernet (integriert)"'");
}
since updating to panther the as part won’t work any more.
tell application "Internet Connect" to connect configuration "Ethernet (integriert)"
It seems as if apple has updated the scripting dictionary w/o updating the documentaion. according to the dictionary the old code should still work. i couldn’t find any working alternative. I also tried to do it w/o as but had no sucess so far in scripting the cl-interface of pppd.
Try to catch the command that the “Internet Connect” Software sends under the hood to connect while you are connected. issue the following in the shell:
I don’t know if it’s changed at all, but if you look at the dictionary for Internet Connect, you’ll see that ‘connect’ has a ‘reference’ parameter. This usually means that you need to tell it what you want to connect.
At a guess, I’d think something like:
tell application "Internet Connect"
connect PPP configuration 1
end tell
would work. You need to be explicit in what you want it to connect to. It may be that earlier versions made assumptions about what to connect, or it may be that 10.3 adds additional configurations that didn’t exist under 10.2. I can’t tell since I never use Internet Connect, so I don’t know what it used to look like.
As to why the original poster’s script (which does include a reference to the configuration to use) fails, I have no idea. I assume you’ve checked the configuration exists, same spelling, etc.?
since i can’t find a way to force a PPPoE connect, (neither shell nor applescript work) i tried to solve the problem by enabling “connect when requested” in PPPoE-Options and launching an app the tries to connect. This also didn’t work. only if i start my machine it automatically connects now.
So instead of reconnecting when i get disconnected i just shutdown and restart my machine at fixed times.
i feel really stupid for doing that this way but iT#s the only way to keep my machine online i know.
The following script fails to connect via Internet Connect. If I substitute disconnect for connect then the script to disconnect me from DSL/Ethernet connection.
I’m kind of new to Applescript. I had the same problem with a script to connect my ADSL connection that broke after I updated to Panther. After some research I came to the conclusion that we must now control Internet Connect with GUI scripts. I found this info on the Apple website http://www.apple.com/applescript/uiscripting/index.html
So I have written a new script that works well for me; it makes my connection, opens and hides Mail, opens the NetNewsWire application and closes the window, because I use the app from the dock, and opens a weather bug for my menubar called Meteorology.
I saved the script as an application without the startup screen and placed it in my login items. Now all those little things I like when I finally sit down at the computer to work in the morning, all happen behind the scene once again in Panther, the way they used to in Jaguar!
Feel free to uses it as you like!
tell application “Internet Connect”
activate
end tell
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
delay 30
tell application “Internet Connect”
quit
end tell
tell application “Mail” to activate
tell application “System Events”
tell process “Mail”
tell menu bar 1
tell menu bar item “Mail”
tell menu “Mail”
click menu item “Hide Mail”
end tell
end tell
end tell
end tell
end tell
tell application “NetNewsWire” to activate
tell application “System Events”
tell process “NetNewsWire”
tell menu bar 1
tell menu bar item “Window”
tell menu “Window”
click menu item “Close”
end tell
end tell
end tell
end tell
end tell
delay 10
I can’t help with Internet Connect but here’s some code for Mail and NNW that doesn’t rely on scripting the UI.
tell application "Mail" to launch
tell application "System Events" to set visible of process "Mail" to false
tell application "NetNewsWire" to ¬
try
close front window
end try
Tested with Mail 1.2.5, NNW 1.0.8 and OS X 10.2.8.