4 Replies Latest reply: Apr 7, 2013 11:07 AM by g_wolfman
Koohyar Hadjisalimi Level 1 Level 1 (0 points)

I know the exact key/value to be changed; it's in

/Library/Preferences/SystemConfiguration/preferences.plist -> NetworkServices -> 46A40FA8-6E7C-xxxx-xxxx-xxxxxxxxxxx -> Proxies -> HTTP(S)Enable ->  should be set to 1

 

I immdediately thought of using defaults write to carry this out in the command line but I don't know how (or if at all!) that works with multi-level key/values. I only have access to the first level (NetworkServices) with defaults read.

Any help would be much appreciated,

thanks \.



OS X Mountain Lion (10.8.3)
  • Koohyar Hadjisalimi Level 1 Level 1 (0 points)

    Okay so thanks to this thread https://discussions.apple.com/message/6212689#6212689

    I could use PlistBuddy (located in /usr/libexec) to set the key HTTP(S)Enable to 1, and then save it:

     

    sudo /usr/libexec/PlistBuddy -c "Set NetworkServices:46A40FA8-6E7C-xxxx-xxxx-xxxxxx:Proxies:HTTPSEnable 0" /Library/Preferences/SystemConfiguration/preferences.plist

     

    sudo /usr/libexec/PlistBuddy -c Save /Library/Preferences/SystemConfiguration/preferences.plist

     

    but my connection doesn't feel a thing! There's no indication of it working in the browser and when I go to Network Preferences, the HTTP and HTTPS proxies are still unchecked.

    Do I need to 'restart' any service for this to take effect?\.

  • Koohyar Hadjisalimi Level 1 Level 1 (0 points)

    Well I find the final solution (and this is awkwardly turning into an internal dialogue!)

    In this same thread: https://discussions.apple.com/message/6212689#6212689 there's notion of a very powerful interface called networksetup located in /usr/sbin/networksetup a quick look at its manual page tells quite a lot about its capabilites.

    So the two simple commands for enabling/disabling HTTP and HTTPS are:

    $ /usr/sbin/networksetup -setwebproxystate Wi-Fi [on|off]

    $ /usr/sbin/networksetup -setsecurewebproxystate Wi-Fi [on|off]

     

    \.

  • MrHoffman Level 6 Level 6 (13,150 points)

    FWIW, some previous (older) discussions of establishing automatic DHCP settings for web proxies, if that might be of interest to you.

     

    https://discussions.apple.com/thread/2606796?start=0&tstart=0

    https://discussions.apple.com/thread/2516293?start=0&tstart=0

    https://discussions.apple.com/thread/2309560?start=0&tstart=0

     

    The  DHCP Option Code Utility tool mentioned there is still posted around the 'net, but it's no longer available via me.com.  I don't know that it works on recent versions.  I'd see if the wpad stuff works without that.

     

    Some of the older forum postings have problems with the underscores in symbols, and have corresponding mistranslated those as underlining.

  • g_wolfman Level 4 Level 4 (1,120 points)

    The networksetup utility is the program OS X uses to change the network configuration.  The Network Preference Pane in system preferences is just a front end to networksetup; networksetup can do everything the preference pane can do (and possibly more).

     

    The parameters you are interested in (from the man page):

     

     

    -getwebproxy networkservice

     

    Displays Web proxy (server, port, enabled value) info for <networkservice>.

     

     

    -setwebproxy networkservice domain portnumber authenticated username password

     

    Set Web proxy for <networkservice> with <domain> and <port number>. Turns proxy on. Optionally, specify <on> or <off> for <authenticated> to enable and disable authenticated proxy support.  Specify <username> and <password> if you turn authenticated proxy support on.

     

     

    -setwebproxystate networkservice on | off

     

    Set Web proxy on <networkservice> to either <on> or <off>.

     

     

    -getsecurewebproxy networkservice

     

    Displays Secure Web proxy (server, port, enabled value) info for <networkservice>.

     

     

    -setsecurewebproxy networkservice domain portnumber authenticated username password

     

    Set Secure Web proxy for <networkservice> with <domain> and <port number>. Turns proxy on.  Optionally, specify <on> or <off> for <authenticated> to enable and disable authenticated proxy support. Specify <username> and <password> if you turn authenticated proxy support on.

     

     

    -setsecurewebproxystate networkservice on | off

     

    Set SecureWeb proxy on <networkservice> to either <on> or <off>.