| |
| | |

Apple Phoon Forum

 Forgot password?
 Register
View: 784|Reply: 4

How can I set enable HTTP and/or HTTPS Proxies through command line?

[Copy link]

Post time: 2014-02-05 19:53:53 |Show all posts
Networking and the Web
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)
Reply

Use magic Report

Post time: 2014-02-06 02:24:46 |Show all posts
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):
Reply

Use magic Report

Post time: 2014-02-06 00:34:19 |Show all posts
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.
Reply

Use magic Report

Post time: 2014-02-05 23:16:05 |Show all posts
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 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]
\.
Reply

Use magic Report

Post time: 2014-02-05 21:53:24 |Show all posts
Okay so thanks to this thread https://discussions.apple.com/message/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?\.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Archive| Apple Phoon

2021-04-18 06:08 GMT-8 , Processed in 0.084866 sec., 27 queries .

Powered by Discuz! 7.2

Release 20121101, © 2001-2021

To Top