Created
May 1, 2014 17:22
-
-
Save ceaser/7edb5c67c650092cd00a to your computer and use it in GitHub Desktop.
Detecting if a proxy is used for the active Network Location on a specific adaptor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ "`networksetup -getwebproxy 'USB Ethernet' | awk {'print $2'} | head -n 1 | tr -d ' '`" = "Yes" ]; then | |
export HTTP_PROXY=`networksetup -getwebproxy 'USB Ethernet' | awk {'print $2'} | awk {'getline l2; getline l3; print "http://"l2":"l3'} | head -n 1` | |
export HTTPS_PROXY=$HTTP_PROXY | |
export ALL_PROXY=$HTTP_PROXY | |
export http_proxy=$HTTP_PROXY | |
export https_proxy=$HTTP_PROXY | |
export all_proxy=$HTTP_PROXY | |
echo "Using $HTTP_PROXY as a Proxy" | |
else | |
unset HTTP_PROXY | |
unset HTTPS_PROXY | |
unset ALL_PROXY | |
unset http_proxy | |
unset https_proxy | |
unset all_proxy | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment