Applying changes once a plist file has been changed

Hi,

Firstly thanks for reading my thread. I’ve just written a quit script to change the service order of my network adapters between my 3G Wireless Dongle and my Ethernet when I am at work.

It’s a but messy but it just copies out a plist depending on which order they currently are see below:


set _file to "/Library/Preferences/SystemConfiguration/preferences.plist"
set _contents to read _file
set _mepath to path to me as string

if _contents contains "<key>ServiceOrder</key>
						<array>
							<string>15A4E17E-0525-4792-933E-7B1E0FAC7AF4</string>
							<string>353E5982-216F-4A7A-BB87-62EA104B995C</string>
							<string>5C0E5611-B65C-43C4-9F06-C13F9D5DCBBB</string>
							<string>1469F397-4294-4129-9A49-F3584F5E3B98</string>
							<string>065CF19D-046C-4B6F-A40A-31AFB0DC0E14</string>
						</array>" then
	set _ethfile to _mepath & "Contents:Resources:eth:preferences.plist"
	set _ethfile to POSIX path of _ethfile
	do shell script "cp " & _ethfile & " /Library/Preferences/SystemConfiguration" user name "USERNAME" password "PASSWORDS" with administrator privileges
	
	
else if _contents contains "<key>ServiceOrder</key>
						<array>
							<string>353E5982-216F-4A7A-BB87-62EA104B995C</string>
							<string>15A4E17E-0525-4792-933E-7B1E0FAC7AF4</string>
							<string>5C0E5611-B65C-43C4-9F06-C13F9D5DCBBB</string>
							<string>1469F397-4294-4129-9A49-F3584F5E3B98</string>
							<string>065CF19D-046C-4B6F-A40A-31AFB0DC0E14</string>
						</array>" then
	set _dongfile to _mepath & "Contents:Resources:dong:preferences.plist"
	set _dongfile to POSIX path of _dongfile
	do shell script "cp " & _dongfile & " /Library/Preferences/SystemConfiguration" user name "USERNAME" password "PASSWORDS" with administrator privileges
end if

Currently it does actually switch the service but it doesn’t apply the setting which is obviously pretty useless.
Does anyone know of a way to apply the changes or make the correct process re-read the preferences file?

thanks in advance

Dave Maltby

Hi,

DO NOT alter the preferences files in /Library/Preferences/System Configuration.
These files belong to the system and changing could cause fatal errors.

You could create easily different network locations and switch between them

I agree that overwriting /Library/Preferences/SystemConfiguration/preferences.plist like that is not a great idea.

If you can capture your configuration changes via the Location functionality, then you can automate switching locations with do shell script and scselect.

Hey,

Thanks for your input. I’m not editing the plist I’m copying out 2 different plists created by the system but yea I agree it’s dodgy.

The problem is that I can’t access any network resources when the 3G Dongle is first in the service order but I like the 3G dongle to be first because of internet restrictions at work (You can’t even type updating into Google -_-).

The problem is if I use a location the 3G Dongle gets the connection hung up so it’s just as much work as setting the service order by hand.

Any other ideas would be greatly appreciated.

Dave Maltby