Home » Questions » Computers [ Ask a new question ]

How can I get Mac OS X's proxy information in a Bash script?

How can I get Mac OS X's proxy information in a Bash script?

I have several network locations set up on my laptop: Work, Home, etc. The work one(s) all have a proxy server set up, while the others don't. This works fine for OSX applications -- Safari, Mail, even Firefox and Thunderbird with the System Proxy plugin.

Asked by: Guest | Views: 424
Total answers/comments: 4
Guest [Entry]

"The following seems to work, but I'm not sure how robust it is:

system_profiler SPNetworkDataType|grep ""HTTP Proxy Server""|awk {'sub(/^.*:[ \t]*/, """", $0); print $0;'}

It doesn't work if your Location uses a proxy.pac instead of a hard-coded proxy location."
Guest [Entry]

"The following seems to work, but I'm not sure how robust it is:

system_profiler SPNetworkDataType|grep ""HTTP Proxy Server""|awk {'sub(/^.*:[ \t]*/, """", $0); print $0;'}

It doesn't work if your Location uses a proxy.pac instead of a hard-coded proxy location."
Guest [Entry]

Additionally this command may help to discover other proxy settings : scutil --proxy
Guest [Entry]

"I just did this scutil --proxy and copied the HTTPPort parameters and the HTTPProxy parameters.
Then I did this export ALL_PROXY=HTTPPort:HTTPProxy where you will replace the HTTPPort and HTTPProxy with your parameters.
Then finally, I did this /bin/bash -c ""$(curl -fsSL raw.githubusercontent.com/Homebrew/install/master/install.sh)""
Now you're good to go."