Enable and Disable Sock proxy for Ethernet and Airport connections

I am very new to apple as well as apple script. After being a long time windows user, I finally made the swtich :smiley:

In my windows environment, I had the ability to write a script that would enable the proxy and go about my merry way.

I am trying to do the same thing on the mac.

what I would like to do is write an apple script that would enable the Sock Proxy on both network cards. It seems to be a simple task, but I am still getting used to the apple plate form.

Any help or advice to get me started would be much appericated.

Cheers

My thought would be to set up different locations in the network preferences for each different setting you would like to use. Then you could use applescript to change to your different locations. So, after you set up your locations this code should get you started changing between themā€¦

to determine your current locationā€¦

set current_location to do shell script "scselect 2>&1 | grep '^ ' 2>&1 | grep '*' | cut -f 2 -d '(' | cut -f 1 -d ')'"

to change your network settings to a different location (for example if ā€œsocks_enabledā€ is the location you want)ā€¦

do shell script "scselect 'socks_enabled'"

So finally putting the two together you can use something like this. This assumes you have made two different locations and you want to switch back and forth between the twoā€¦

set location_1 to "socks_enabled" -- this is the name of the location with your socks settings enabled
set location_2 to "socks_disabled" -- this is the name of the location with your socks settings disabled

set current_location to do shell script "scselect 2>&1 | grep '^ ' 2>&1 | grep '*' | cut -f 2 -d '(' | cut -f 1 -d ')'"
if current_location is location_1 then
	do shell script "scselect '" & location_2 & "'"
else
	do shell script "scselect '" & location_1 & "'"
end if

Hope this helps.