Ticking Auto Proxy Discovery in 10.6.X

ibayssari
New Contributor II

Hi,
This will tick the auto proxy discovery tickbox in 10.6.X machines.

#!/bin/bash

# Mac OS X 10.6.X
# Date: 09/2012
# Author: Isaac Bayssari

# This will tick the auto proxy discovery tick box for 10.6.X machines.

echo "list Setup:/Network/Service/[^/]+/Proxies" | scutil | awk '{print $4}' | cut -c 24-59 | while read serviceid; do /usr/libexec/PlistBuddy -c "Add :NetworkServices:$serviceid:Proxies:ProxyAutoDiscoveryEnable integer 1" /Library/Preferences/SystemConfiguration/preferences.plist ;/usr/libexec/PlistBuddy -c "Set :NetworkServices:$serviceid:Proxies:ProxyAutoDiscoveryEnable 1" /Library/Preferences/SystemConfiguration/preferences.plist; done

Please email me if you would like a copy of this script.

ibayssari2@parra.catholic.edu.au

1 ACCEPTED SOLUTION

ibayssari
New Contributor II

Hi tim,
My Post Title Should Read "SOLVED:Ticking Auto Proxy Discovery in 10.6.X"

My post is putting a tick within the "Auto Proxy Discovery". The below and above script does this.

#!/bin/bash

# Mac OS X 10.6.X
# Date: 09/2012
# Author: Isaac Bayssari

# This will tick the auto proxy discovery tick box for 10.6.X machines.

echo "list Setup:/Network/Service/[^/]+/Proxies" | scutil | awk '{print $4}' | cut -c 24-59 | while read serviceid; do /usr/libexec/PlistBuddy -c "Add :NetworkServices:$serviceid:Proxies:ProxyAutoDiscoveryEnable integer 1" /Library/Preferences/SystemConfiguration/preferences.plist ;/usr/libexec/PlistBuddy -c "Set :NetworkServices:$serviceid:Proxies:ProxyAutoDiscoveryEnable 1" /Library/Preferences/SystemConfiguration/preferences.plist; done

Please email me if you would like a copy of this script.

ibayssari2@parra.catholic.edu.au

Thanks

View solution in original post

7 REPLIES 7

tkimpton
Valued Contributor II

Try script 1. Thanks Ben :)

http://macmule.com/2011/09/09/how-to-change-the-automatic-proxy-configuration-url-in-system-preferences-via-a-script/

ibayssari
New Contributor II

Hi tim,
My Post Title Should Read "SOLVED:Ticking Auto Proxy Discovery in 10.6.X"

My post is putting a tick within the "Auto Proxy Discovery". The below and above script does this.

#!/bin/bash

# Mac OS X 10.6.X
# Date: 09/2012
# Author: Isaac Bayssari

# This will tick the auto proxy discovery tick box for 10.6.X machines.

echo "list Setup:/Network/Service/[^/]+/Proxies" | scutil | awk '{print $4}' | cut -c 24-59 | while read serviceid; do /usr/libexec/PlistBuddy -c "Add :NetworkServices:$serviceid:Proxies:ProxyAutoDiscoveryEnable integer 1" /Library/Preferences/SystemConfiguration/preferences.plist ;/usr/libexec/PlistBuddy -c "Set :NetworkServices:$serviceid:Proxies:ProxyAutoDiscoveryEnable 1" /Library/Preferences/SystemConfiguration/preferences.plist; done

Please email me if you would like a copy of this script.

ibayssari2@parra.catholic.edu.au

Thanks

tkimpton
Valued Contributor II

i've found Bens script 1 to work for 10.6 and 10.8 specifying not on ticking it but also the location of the auto configuration file. To others looking i really would suggest Bens method.

bentoms
Release Candidate Programs Tester

Ha ha ha Tim, my virtual Pimp!!

craig_george
New Contributor

Tkimpton - do you have script that runs both that you can share?

tkimpton
Valued Contributor II

link i posted.

This is what i use

#!/bin/sh
##################################################################################
#
# HISTORY
#
# Version: 1.0
#
# - Created by Ben Toms on Jul 28th, 2011
#
# Sets the "Automatic Proxy Configuration" url in System Preferences.
#
# For more info see:
# http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/networksetup.8.html
#
###################################################################################
# HARDCODED VALUES ARE SET HERE
autoProxyURL="file://localhost/proxy.pac"

# CHECK TO SEE IF A VALUE WAS PASSED FOR $4, AND IF SO, ASSIGN IT
if [ "$4" != "" ] && [ "$autoProxyURL" == "" ]; then
autoProxyURL=$4
fi

# Detects all network hardware & creates services for all installed network hardware
/usr/sbin/networksetup -detectnewhardware

IFS=$'
'

#Loops through the list of network services
for i in $(networksetup -listallnetworkservices | tail +2 );
do

# Get a list of all services beginning 'Ether' 'Air' or 'VPN' or 'Wi-Fi'
# If your service names are different to the below, you'll need to change the criteria
if [[ "$i" =~ 'Ether' ]] || [[ "$i" =~ 'Air' ]] || [[ "$i" =~ 'VPN' ]] || [[ "$i" =~ 'Wi-Fi' ]] ; then
autoProxyURLLocal=`/usr/sbin/networksetup -getautoproxyurl "$i" | head -1 | cut -c 6-`

# Echo's the name of any matching services & the autoproxyURL's set
echo "$i Proxy set to $autoProxyURLLocal"

# If the value returned of $autoProxyURLLocal does not match the value of $autoProxyURL for the interface $i, change it.
if [[ $autoProxyURLLocal != $autoProxyURL ]]; then
networksetup -setautoproxyurl $i $autoProxyURL
echo "Set proxy for $i to $autoProxyURL"
fi
fi

done

echo "Proxies All Present And Correct..."

unset IFS

bbass
Contributor

I thought I'd update this post with an edit of Ben's script. This should tick the Auto Proxy Discovery checkbox in 10.8.

This won't solve the OP's problem but at least it will provide an answer to those folks on later versions of the OS who find this thread via a Google search.

#!/bin/sh

# Detects all network hardware & creates services for all installed network hardware
/usr/sbin/networksetup -detectnewhardware

IFS=$'
'

#Loops through the list of network services
for i in $(networksetup -listallnetworkservices | tail +2 );
do

# Get a list of all services beginning 'Ether' 'Air' or 'VPN' or 'Wi-Fi'

# If your service names are different to the below, you'll need to change the criteria
if [[ "$i" =~ 'Ether' ]] || [[ "$i" =~ 'Air' ]] || [[ "$i" =~ 'VPN' ]] || [[ "$i" =~ 'Wi-Fi' ]] ; then
    autoProxyDiscStatus=`networksetup -getproxyautodiscovery $i | awk '{ print $4 }'`

    # Echo's the name of any matching services & the autoproxyURL's set
    echo "$i Proxy set to $autoProxyDiscStatus"

    # If the value returned of $autoProxyURLLocal does not match the value of $autoProxyURL for the interface $i, change it.
    if [[ $autoProxyDiscStatus != On ]]; then
        networksetup -setproxyautodiscovery $i On
        echo "Set proxy for $i to On"
    fi
fi

done

echo "Proxies All Present And Correct..."

unset IFS